From 4219bcf681d06c04cc97fc424a4ed2d8fb27bb96 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Wed, 4 Oct 2023 18:14:28 -0400 Subject: [PATCH 1/3] encodes page in description url --- modules/dfpAdServerVideo.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index 3394fd8b3f4..a3e26dc7202 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -249,7 +249,9 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) { */ function buildUrlFromAdserverUrlComponents(components, bid, options) { const descriptionUrl = getDescriptionUrl(bid, components, 'search'); - if (descriptionUrl) { components.search.description_url = descriptionUrl; } + if (descriptionUrl) { + components.search.description_url = descriptionUrl; + } components.search.cust_params = getCustParams(bid, options, components.search.cust_params); return buildUrl(components); @@ -264,7 +266,7 @@ function buildUrlFromAdserverUrlComponents(components, bid, options) { * @return {string | undefined} The encoded vast url if it exists, or undefined */ function getDescriptionUrl(bid, components, prop) { - return deepAccess(components, `${prop}.description_url`) || dep.ri().page; + return deepAccess(components, `${prop}.description_url`) || encodeURIComponent(dep.ri().page); } /** From 69e331a4924ecd3e65d982c23da0ba4f4354ffbb Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Wed, 4 Oct 2023 22:24:27 -0400 Subject: [PATCH 2/3] adds test --- test/spec/modules/dfpAdServerVideo_spec.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index 89485adf28b..8c443fe5b50 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -58,8 +58,18 @@ describe('The DFP video support module', function () { }, options))); const prm = utils.parseQS(url.query); expect(prm.description_url).to.eql('example.com'); + }); + + it('should use a URI encode page location as default for description_url', () => { + sandbox.stub(dep, 'ri').callsFake(() => ({page: 'https://example.com?iu=/99999999/news&cust_params=current_hour%3D12%26newscat%3Dtravel&pbjs_debug=true'})); + const url = parse(buildDfpVideoUrl(Object.assign({ + adUnit: adUnit, + bid: bid, + }, options))); + const prm = utils.parseQS(url.query); + expect(prm.description_url).to.eql('https%3A%2F%2Fexample.com%3Fiu%3D%2F99999999%2Fnews%26cust_params%3Dcurrent_hour%253D12%2526newscat%253Dtravel%26pbjs_debug%3Dtrue'); }) - }) + }); }) it('should make a legal request URL when given the required params', function () { From baf459afb899c26da7d446175437de2d7c5fb69d Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Wed, 4 Oct 2023 22:29:02 -0400 Subject: [PATCH 3/3] typo --- test/spec/modules/dfpAdServerVideo_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index 8c443fe5b50..4c12e9fa211 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -60,7 +60,7 @@ describe('The DFP video support module', function () { expect(prm.description_url).to.eql('example.com'); }); - it('should use a URI encode page location as default for description_url', () => { + it('should use a URI encoded page location as default for description_url', () => { sandbox.stub(dep, 'ri').callsFake(() => ({page: 'https://example.com?iu=/99999999/news&cust_params=current_hour%3D12%26newscat%3Dtravel&pbjs_debug=true'})); const url = parse(buildDfpVideoUrl(Object.assign({ adUnit: adUnit, @@ -68,7 +68,7 @@ describe('The DFP video support module', function () { }, options))); const prm = utils.parseQS(url.query); expect(prm.description_url).to.eql('https%3A%2F%2Fexample.com%3Fiu%3D%2F99999999%2Fnews%26cust_params%3Dcurrent_hour%253D12%2526newscat%253Dtravel%26pbjs_debug%3Dtrue'); - }) + }); }); })