Skip to content

Commit

Permalink
Prevent renderAd from overwriting the website DOM document (prebid#607)
Browse files Browse the repository at this point in the history
* Ensure that we’re not writing to the current document

* Check for current document access after marking the ad as winning bid
  • Loading branch information
kasparsd authored and studnicky committed Oct 4, 2016
1 parent f59e08c commit 28d5030
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
var url = adObject.adUrl;
var ad = adObject.ad;

if (ad) {
if (doc===document) {
utils.logError('Error trying to write ad. Ad render call ad id ' + id + ' was prevented from writing to the main document.');
} else if (ad) {
doc.write(ad);
doc.close();
if (doc.defaultView && doc.defaultView.frameElement) {
Expand Down

0 comments on commit 28d5030

Please sign in to comment.