Skip to content

Parse query string in using URLSearchParams #14271

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

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

calixteman
Copy link
Contributor

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 13, 2021

I just noticed in reading the code that we parse that stuff when something exists in the web api;

For reference: Note that this PDF.js code actually pre-dates the existence of the URLSearchParams functionality, which is why this code looks the way it does. In particular Safari were quite slow, comparatively, to implement URLSearchParams support.

If we're making these changes, shouldn't the following code be updated similar to the web/ui_utils.js code?

function hashParameters() {
const query = window.location.hash.substring(1);
const params = new Map();
for (const part of query.split(/[&;]/)) {
const param = part.split("="),
key = param[0].toLowerCase(),
value = param.length > 1 ? param[1] : "";
params.set(decodeURIComponent(key), decodeURIComponent(value));
}
return params;
}

@calixteman
Copy link
Contributor Author

If we're making these changes, shouldn't the following code be updated similar to the web/ui_utils.js code?

function hashParameters() {
const query = window.location.hash.substring(1);
const params = new Map();
for (const part of query.split(/[&;]/)) {
const param = part.split("="),
key = param[0].toLowerCase(),
value = param.length > 1 ? param[1] : "";
params.set(decodeURIComponent(key), decodeURIComponent(value));
}
return params;
}

In this code we split on & and ; when URLSearchParams handles only & as separator, it's why I didn't change it.
Is this ; here because it has been forgotten or do we really have some urls containing it ?

@Snuffleupagus
Copy link
Collaborator

Is this ; here because it has been forgotten or do we really have some urls containing it ?

As mentioned at the top of that file, that code was originally imported from Firefox and the "special" separator pattern thus came from the original file.
As far as I can find, we only have a single call-site that invoke the reftest-analyzer code and there we're only passing one hash-parameter; see

const startUrl = `http://${host}:${server.port}/test/resources/reftest-analyzer.html#web=/test/eq.log`;

Hence, as long as all tests and the reftest-analyzer itself works, I believe that it's should be safe to change that one as well.

 - I just noticed in reading the code that we parse that stuff when something exists in the web api;
 - see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams.
@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/6a3431c663788e8/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/03c9f802892c5dd/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/03c9f802892c5dd/output.txt

Total script time: 24.07 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 13
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/03c9f802892c5dd/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/6a3431c663788e8/output.txt

Total script time: 41.52 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 8
  different first/second rendering: 1

Image differences available at: http://54.193.163.58:8877/6a3431c663788e8/reftest-analyzer.html#web=eq.log

@Snuffleupagus Snuffleupagus merged commit 7a42834 into mozilla:master Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants