Skip to content

Fix #20420: Prevent double decoding of file URL parameter#20482

Merged
timvandermeij merged 1 commit intomozilla:masterfrom
Uzair-Ahmed-Shah:fix-issue-20420
Dec 13, 2025
Merged

Fix #20420: Prevent double decoding of file URL parameter#20482
timvandermeij merged 1 commit intomozilla:masterfrom
Uzair-Ahmed-Shah:fix-issue-20420

Conversation

@Uzair-Ahmed-Shah
Copy link
Contributor

Fixes #20420

Description

This PR fixes a regression where passing a URL with encoded parameters (e.g., ?token=%2Ffoo) to the viewer would fail due to incorrect double decoding.

  • The Bug: In web/app.js, the file parameter retrieved from URLSearchParams was being passed to decodeURIComponent. Since URLSearchParams.get() already decodes values, this caused a second round of decoding. This corrupted URLs containing encoded characters (like %2F becoming /), which broke signed URLs or paths requiring encoding.
  • The Fix: Removed the redundant decodeURIComponent call. The file parameter is now passed directly to the URL constructor, preserving the correct encoding.

Testing

Verified manually using a reproduction case:

  1. Input: https://example.com/pdf?token=%2Ffoo
  2. Before Fix: Resulted in ...token=/foo (Incorrect, broke the token).
  3. After Fix: Results in ...token=%2Ffoo (Correct, preserves encoding).

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(re-adding the "request changes" that disappeared because the comment above is not addressed yet)

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me, but please squash the commits into one (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits if you're not familiar with how to do that). After that we can trigger the integration tests.

@timvandermeij
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 1

Live output at: http://54.241.84.105:8877/6685b2f5ba9465a/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 1

Live output at: http://54.193.163.58:8877/9a30ae3ca91a5d3/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/6685b2f5ba9465a/output.txt

Total script time: 20.26 mins

  • Integration Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/9a30ae3ca91a5d3/output.txt

Total script time: 41.55 mins

  • Integration Tests: Passed

@timvandermeij timvandermeij merged commit 8b4fae0 into mozilla:master Dec 13, 2025
7 checks passed
@timvandermeij
Copy link
Contributor

Thank you for your contribution!

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.

[Bug]: Passing relative or protocol-less URL to viewer file param fails to open file correctly

3 participants