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

Change the parseQueryString function to return a Map rather than an Object (issue 13829) #13831

Merged
merged 1 commit into from
Aug 1, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Jul 31, 2021

Even though the code as-is should be safe, given that we're using an Object with a null prototype, it cannot hurt to change this to a Map to prevent any issues (since we're parsing unknown and potentially unsafe data).

Overall I also think that these changes improve the parseQueryString call-sites, since we now have a proper way of checking for the existence of a particular key (and don't have to use in which stringifies the keys in the Object).

This patch also changes the default, when no value exists, from null to an empty string since the use of decodeURIComponent currently can modify the value in a somewhat surprising way (at least to me).
Note how decodeURIComponent(null) === "null" which is unlikely to be what you actually want, whereas decodeURIComponent("") === "" which seems much more helpful.

Edit: https://github.com/mozilla/pdf.js/pull/13831/checks?check_run_id=3210760893

…an Object (issue 13829)

Even though the code as-is *should* be safe, given that we're using an Object with a `null` prototype, it cannot hurt to change this to a Map to prevent any issues (since we're parsing unknown and potentially unsafe data).

Overall I also think that these changes improve the `parseQueryString` call-sites, since we now have a proper way of checking for the existence of a particular key (and don't have to use `in` which stringifies the keys in the Object).

This patch also changes the default, when no `value` exists, from `null` to an empty string since the use of `decodeURIComponent` currently can modify the value in a somewhat surprising way (at least to me).
Note how `decodeURIComponent(null) === "null"` which is unlikely to be what you actually want, whereas `decodeURIComponent("") === ""` which seems much more helpful.
@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://3.101.106.178:8877/c28512f63c2e27b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/4d541c96b3b1363/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/4d541c96b3b1363/output.txt

Total script time: 3.93 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/c28512f63c2e27b/output.txt

Total script time: 5.56 mins

  • Unit Tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

/botio integrationtest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/192a9fb4e95ded9/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://3.101.106.178:8877/f640970299a0d43/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/192a9fb4e95ded9/output.txt

Total script time: 4.31 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/f640970299a0d43/output.txt

Total script time: 5.19 mins

  • Integration Tests: Passed

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Aug 1, 2021

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/4b7960dc480d629/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 1, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/4b7960dc480d629/output.txt

Total script time: 5.56 mins

Published

@timvandermeij timvandermeij merged commit 449f941 into mozilla:master Aug 1, 2021
@timvandermeij
Copy link
Contributor

Looks better and fixes the alert, so let's do this; thanks!

@Snuffleupagus Snuffleupagus deleted the parseQueryString-Map branch August 1, 2021 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants