Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent renderAd from overwriting the website DOM document #607

Merged
merged 2 commits into from
Sep 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need mark the winning bid before bailing out if the ad render call tries to replace the top document. Previously I had placed it right before the if (adObject) check but that's too early.

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