Skip to content

Commit

Permalink
Remove <!doctype> from markup before rendering with postscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Aug 16, 2022
1 parent 2590307 commit 1ab7072
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export function writeAdUrl(adUrl, width, height) {
document.body.appendChild(iframe);
}

export function writeAdHtml(markup) {
postscribe(document.body, markup, {
export function writeAdHtml(markup, doc = document) {
// remove <?xml> and <!doctype> tags
// https://github.com/prebid/prebid-universal-creative/issues/134
markup = markup.replace(/\<(\?xml|(\!DOCTYPE[^\>\[]+(\[[^\]]+)?))+[^>]+\>/g, '');
postscribe(doc.body, markup, {
error: console.error
});
}
Expand Down

0 comments on commit 1ab7072

Please # to comment.