Skip to content

Commit

Permalink
Fix double encoded targeting string in query string
Browse files Browse the repository at this point in the history
Values in the targeting string can include comma (',') and we do not want to double encode those as we will encode again when we build the querystring with createQueryString().
  • Loading branch information
mirkorean committed Jul 21, 2020
1 parent 336bfce commit af0c04c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion modules/yieldlabBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const spec = {
utils._each(validBidRequests, function (bid) {
adslotIds.push(bid.params.adslotId)
if (bid.params.targeting) {
query.t = createQueryString(bid.params.targeting)
query.t = createTargetingString(bid.params.targeting)
}
if (bid.userIdAsEids && Array.isArray(bid.userIdAsEids)) {
query.ids = createUserIdString(bid.userIdAsEids)
Expand Down Expand Up @@ -198,6 +198,23 @@ function createQueryString (obj) {
return str.join('&')
}

/**
* Creates an unencoded targeting string out of an object with key-values
* @param {Object} obj
* @returns {String}
*/
function createTargetingString (obj) {
let str = []
for (var p in obj) {
if (obj.hasOwnProperty(p)) {
let key = p
let val = obj[p]
str.push(key + '=' + val)
}
}
return str.join('&')
}

/**
* Handles an outstream response after the library is loaded
* @param {Object} bid
Expand Down

0 comments on commit af0c04c

Please sign in to comment.