Skip to content

Commit

Permalink
Bugfix/encoding url (#1178)
Browse files Browse the repository at this point in the history
* fix size mapping for s2s

* fixed bug with double encoding cookie sync URL
  • Loading branch information
Matt Kendall authored and Nate Cozi committed May 4, 2017
1 parent 73dfa73 commit efed21e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function fireSyncs() {
queue.forEach(obj => {
utils.logMessage(`Invoking cookie sync for bidder: ${obj.bidder}`);
if(obj.type === 'iframe') {
utils.insertCookieSyncIframe(obj.url);
utils.insertCookieSyncIframe(obj.url, false);
} else {
utils.insertPixel(obj.url);
}
Expand Down
15 changes: 10 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,10 @@ exports.insertPixel = function (url) {
/**
* Inserts empty iframe with the specified `url` for cookie sync
* @param {string} url URL to be requested
* @param {string} encodeUri boolean if URL should be encoded before inserted. Defaults to true
*/
exports.insertCookieSyncIframe = function(url) {
let iframeHtml = this.createTrackPixelIframeHtml(url);
exports.insertCookieSyncIframe = function(url, encodeUri) {
let iframeHtml = this.createTrackPixelIframeHtml(url, encodeUri);
let div = document.createElement('div');
div.innerHTML = iframeHtml;
let iframe = div.firstChild;
Expand All @@ -497,14 +498,18 @@ exports.createTrackPixelHtml = function (url) {
/**
* Creates a snippet of Iframe HTML that retrieves the specified `url`
* @param {string} url plain URL to be requested
* @param {string} encodeUri boolean if URL should be encoded before inserted. Defaults to true
* @return {string} HTML snippet that contains the iframe src = set to `url`
*/
exports.createTrackPixelIframeHtml = function (url) {
exports.createTrackPixelIframeHtml = function (url, encodeUri = true) {
if (!url) {
return '';
}
if(encodeUri) {
url = encodeURI(url);
}

return `<iframe frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0p;width:0p;display:none;" scrolling="no" src="${encodeURI(url)}"></iframe>`;
return `<iframe frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" width="0" hspace="0" vspace="0" height="0" style="height:0p;width:0p;display:none;" scrolling="no" src="${url}"></iframe>`;
};

/**
Expand Down Expand Up @@ -653,4 +658,4 @@ export function getBidderRequest(bidder, adUnitCode) {
return request.bids
.filter(bid => bid.bidder === bidder && bid.placementCode === adUnitCode).length > 0;
}) || { start: null, requestId: null };
}
}

0 comments on commit efed21e

Please sign in to comment.