prebid / prebid-universal-creative

Apache License 2.0
43 stars 69 forks source link

Ad markup with <!DOCTYPE html> fails to render on web #209

Closed vraybaud closed 1 year ago

vraybaud commented 1 year ago

Describe the bug If an ad markup contains the <!DOCTYPE html> preamble, it silently stops parsing and only the HTML up to that point is inserted into the document. There is a old issue linked to that : https://github.com/prebid/prebid-universal-creative/issues/134

To Reproduce From prebid server return any ad markup with <!DOCTYPE html> (eg. <!DOCTYPE html>

test

) and inspect the DOM in chrome://inspect. Removing the doctype preamble renders the ad as expected.

Expected behavior Render the ad with doctype correctly as on the web with prebid.js.

Screenshots With version 1.14.2: image

With version 1.15.0: image

Desktop (please complete the following information):

dgirardi commented 1 year ago

I am unable to reproduce; do you have a link to a page that shows the issue? Or otherwise, your GAM creative code (where you load and set up PUC)? are you using safeframe?

From the OP I think you are attempting to render into the main document (rather than an iframe) - and I can't figure out how that would happen, nor do I see anything obvious introduced after 1.14.2.

dgirardi commented 1 year ago

Just noticed this:

From prebid server

is "server" important - are you using AMP or another environment without Prebid.js?

bretg commented 1 year ago

Spent way too long digging into this and found something possibly interesting:

At least in the AMP and App workflow, the PUC is forcing in a comment at the very beginning of the creative, so when DOCTYPE is specified, it looks like this:

<!--Creative 1111 served by Prebid.js Header Bidding--><!DOCTYPE html><img src="https://files.prebid.org/creatives/prebid300x250.png">

Maybe it's invalid HTML to have a comment before the DOCTYPE?

dgirardi commented 1 year ago

It turns out this is a regression to exactly the same issue #134 - affecting app/amp/mobile but not web as far as I can tell.