Closed Bug 2020112 Opened 8 months ago Closed 8 months ago

Firefox strips \t\n\r characters from location.hash, but not from about:blank and data: iframes' hashes

Categories

(Core :: DOM: Window and Location, defect)

defect

Tracking

()

RESOLVED FIXED
150 Branch
Tracking Status
firefox-esr140 --- wontfix
firefox148 --- wontfix
firefox149 --- wontfix
firefox150 --- fixed

People

(Reporter: cpeterson, Assigned: jjaschke)

References

Details

Attachments

(1 file, 1 external file)

Firefox strips \t\n\r characters from location.hash, but not from about:blank and data: iframes' hashes.

Chrome and Safari strip \t\n\r characters from location.hash and about:blank and data: iframes' hashes.

Steps to reproduce

  1. Load about:blank or data:text/html,test in a tab
  2. In the web console, enter location.hash = "foo \t\n\rbar"
  3. Check the value of location.hash

Expected value

#foo%20bar like in Chrome and Safari.

Actual value

#foo%20%09%0A%0Dbar

I found this bug while debugging location.hash bug 1733797. I'll add a WPT test case for this issue in that bug, marked as expected to fail and to be fixed in this bug.

Severity: -- → S3
Flags: needinfo?(jjaschke)

nsSimpleURI::SetRef was not stripping \t, \n, \r characters from the input,
unlike nsStandardURL::SetRef. This caused data: and about:blank URLs to
percent-encode these characters instead of removing them.

Per the URL spec, the hash setter invokes the basic URL parser
(https://url.spec.whatwg.org/#concept-basic-url-parser) which unconditionally
strips all ASCII tab or newline (https://infra.spec.whatwg.org/#ascii-tab-or-newline)
from the input in step 3, before any state-specific processing.

Assignee: nobody → jjaschke
Status: NEW → ASSIGNED
Pushed by jjaschke@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5568c2b3951b https://hg.mozilla.org/integration/autoland/rev/29c96f6a9fdf Strip ASCII tab and newline from fragment in nsSimpleURI::SetRef. r=necko-reviewers,valentin
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
Flags: needinfo?(jjaschke)

The patch landed in nightly and beta is affected.
:jjaschke, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(jjaschke)
Flags: needinfo?(jjaschke)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: