From efed21e6d0e967d5d2b714dd32ae07f5499e4b47 Mon Sep 17 00:00:00 2001 From: Matt Kendall Date: Thu, 4 May 2017 18:53:13 -0400 Subject: [PATCH] Bugfix/encoding url (#1178) * fix size mapping for s2s * fixed bug with double encoding cookie sync URL --- src/cookie.js | 2 +- src/utils.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cookie.js b/src/cookie.js index d4c15fb0d8b..4d079af5564 100644 --- a/src/cookie.js +++ b/src/cookie.js @@ -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); } diff --git a/src/utils.js b/src/utils.js index 5b6542d457f..2ff853920fd 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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; @@ -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 ``; + return ``; }; /** @@ -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 }; -} \ No newline at end of file +}