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

Bugfix/encoding url #1178

Merged
merged 2 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
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: 4 additions & 0 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ exports.callBids = ({adUnits, cbTimeout}) => {

//filter out client side bids
adUnitsCopy.forEach((adUnit) => {
if (adUnit.sizeMapping) {
adUnit.sizes = mapSizes(adUnit);
delete adUnit.sizeMapping;
}
adUnit.sizes = transformHeightWidth(adUnit);
adUnit.bids = adUnit.bids.filter((bid) => {
return adaptersServerSide.includes(bid.bidder);
Expand Down
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 };
}
}