-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Formatting Query String doesn't properly encode #10514
Comments
I agree that some refactoring is warranted, but unfortunately the "wrong" version is used in many places, with many callers assuming they need to do the encoding themselves - so it cannot be simply "fixed" and I'm not sure we want to try to refactor everything (you cannot always tell from the code whether the inputs are already URL-encoded). Do you have more details on where specifically this is a problem? Could it be fixed by switching to the alternate version? |
This might be one: Prebid.js/modules/dfpAdServerVideo.js Lines 139 to 143 in 32c1bf6
|
I am not able to spot the issue from the demo page - but I'm not sure what I'm looking for. The code appears to know that it should encode Prebid.js/modules/dfpAdServerVideo.js Line 104 in 6d39d8b
|
Flagging jwplayer#59 as a possible 9.0 change to debate |
Committee decided not to change the utility without changing all the places it was used to reflect new behavior. We're not actively planning to take on the larger scoped project as the utility is in widespread use. |
Type of issue
Bug
Description
One of the two functions that can format a query string doesn't correctly encode values.
Two format Functions:
https://github.com/prebid/Prebid.js/blob/master/src/utils.js#L135
https://github.com/prebid/Prebid.js/blob/master/src/utils.js#L1165 --> Doesn't properly encode
Steps to reproduce
Input any URL with query params into this function as an input.
(See test page for more reproduction steps)
Test page
CodePen Extracted Example
https://codepen.io/Josh-Rogan/pen/bGOaMWr?editors=0012
In the following code pen, when a query param contains something similar to a URL with query params, it won't properly encode those into the final string. Looking at the console output
description_url
is not properly parsed.Intermittent Live Test Page
This only works sometimes so may not be the best way to reproduce
Live Test Page
Use network tab to find
gampad/ads?
and sometimes you can see where you end up with additional query params likecust_params
which are not properly within it's variableExpected results
All query params are properly encoded.
Actual results
All query params are not encoded. In particular, if any query param value has a
&
it will pollute the real query params with additional query params.Platform details
Other information
Ideally, we should not be using multiple query string formatting functions. This would be a good opportunity to unify and potentially update to use
URLSearchParams
(https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)Quick Fix
The text was updated successfully, but these errors were encountered: