From 968eadeb660216a875aee0d2eb2442c3ba2c6f13 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 29 May 2024 17:00:47 +0000 Subject: [PATCH] Bug 1873973 - Fix nsStandardURL incorrectly escaped "^" in the path r=necko-reviewers,valentin Differential Revision: https://phabricator.services.mozilla.com/D211898 --- caps/tests/unit/test_uri_escaping.js | 2 +- netwerk/test/unit/test_standardurl.js | 19 +++++++++++++++++++ .../meta/url/a-element-xhtml.xhtml.ini | 7 ------- .../web-platform/meta/url/a-element.html.ini | 7 ------- .../meta/url/url-constructor.any.js.ini | 13 ------------- xpcom/io/nsEscape.cpp | 6 +++--- 6 files changed, 23 insertions(+), 31 deletions(-) diff --git a/caps/tests/unit/test_uri_escaping.js b/caps/tests/unit/test_uri_escaping.js index 7feb58129557..5b388765fb13 100644 --- a/caps/tests/unit/test_uri_escaping.js +++ b/caps/tests/unit/test_uri_escaping.js @@ -23,6 +23,6 @@ function run_test() { Assert.equal( createPrincipal("http://test/foo^bar").exposableSpec, - "http://test/foo%5Ebar" + "http://test/foo^bar" ); } diff --git a/netwerk/test/unit/test_standardurl.js b/netwerk/test/unit/test_standardurl.js index b44289f2e665..8917686130c7 100644 --- a/netwerk/test/unit/test_standardurl.js +++ b/netwerk/test/unit/test_standardurl.js @@ -499,6 +499,25 @@ add_test(function test_hugeStringThrows() { run_next_test(); }); +add_test(function test_caretNotEscaped() { + var url = stringToURL("wss://host/ !\"$%&'()*+,-./:;<=>@[\\]^_{|}~"); + Assert.equal( + url.spec, + "wss://host/%20!%22$%&'()*+,-./:;%3C=%3E@[/]^_%7B|%7D~" + ); + + url = stringToURL("wss://host/abc^.bar"); + Assert.equal(url.spec, "wss://host/abc^.bar"); + + url = stringToURL("wss://host/path/to/something?q=foo^bar"); + Assert.equal(url.spec, "wss://host/path/to/something?q=foo^bar"); + + url = stringToURL("wss://host/#^"); + Assert.equal(url.spec, "wss://host/#^"); + + run_next_test(); +}); + add_test(function test_filterWhitespace() { let url = stringToURL( " \r\n\th\nt\rt\tp://ex\r\n\tample.com/path\r\n\t/\r\n\tto the/fil\r\n\te.e\r\n\txt?que\r\n\try#ha\r\n\tsh \r\n\t " diff --git a/testing/web-platform/meta/url/a-element-xhtml.xhtml.ini b/testing/web-platform/meta/url/a-element-xhtml.xhtml.ini index fc4eb05c251e..85cccd7a88c8 100644 --- a/testing/web-platform/meta/url/a-element-xhtml.xhtml.ini +++ b/testing/web-platform/meta/url/a-element-xhtml.xhtml.ini @@ -596,9 +596,6 @@ [Parsing: @[\\\]^_`{|}~> against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - [Parsing: ?@[\\\]^_`{|}~> against ] expected: FAIL @@ -977,8 +974,4 @@ [Parsing: against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - - [a-element-xhtml.xhtml?include=mailto] diff --git a/testing/web-platform/meta/url/a-element.html.ini b/testing/web-platform/meta/url/a-element.html.ini index 6d698e54809a..33a735bb2be9 100644 --- a/testing/web-platform/meta/url/a-element.html.ini +++ b/testing/web-platform/meta/url/a-element.html.ini @@ -625,9 +625,6 @@ [Parsing: @[\\\]^_`{|}~> against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - [Parsing: ?@[\\\]^_`{|}~> against ] expected: FAIL @@ -1006,8 +1003,4 @@ [Parsing: against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - - [a-element.html?include=mailto] diff --git a/testing/web-platform/meta/url/url-constructor.any.js.ini b/testing/web-platform/meta/url/url-constructor.any.js.ini index 25bdaf4be70d..8a4edb79f74f 100644 --- a/testing/web-platform/meta/url/url-constructor.any.js.ini +++ b/testing/web-platform/meta/url/url-constructor.any.js.ini @@ -403,9 +403,6 @@ [Parsing: @[\\\]^_`{|}~> against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - [Parsing: ?@[\\\]^_`{|}~> against ] expected: FAIL @@ -995,9 +992,6 @@ [Parsing: @[\\\]^_`{|}~> against ] expected: FAIL - [Parsing: @[\\\]^_`{|}~> against ] - expected: FAIL - [Parsing: ?@[\\\]^_`{|}~> against ] expected: FAIL @@ -1206,9 +1200,6 @@ [Parsing: without base] expected: FAIL - [Parsing: @[\\\]^_`{|}~> without base] - expected: FAIL - [url-constructor.any.html?include=file] [Parsing: against ] @@ -1536,10 +1527,6 @@ [Parsing: without base] expected: FAIL - [Parsing: @[\\\]^_`{|}~> without base] - expected: FAIL - - [url-constructor.any.html?include=javascript] [Parsing: without base] expected: FAIL diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index f211ea28096b..353958dc7707 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -278,9 +278,9 @@ static constexpr std::array BuildEscapeChars() { AddUnescapedChars("'.", esc_Username, table); AddUnescapedChars("'.", esc_Password, table); AddUnescapedChars(".", esc_Host, table); // Same as esc_Scheme - AddUnescapedChars("'./:;=@[]|", esc_Directory, table); - AddUnescapedChars("'.:;=@[]|", esc_FileBaseName, table); - AddUnescapedChars("':;=@[]|", esc_FileExtension, table); + AddUnescapedChars("'./:;=@[]^|", esc_Directory, table); + AddUnescapedChars("'.:;=@[]^|", esc_FileBaseName, table); + AddUnescapedChars("':;=@[]^|", esc_FileExtension, table); AddUnescapedChars(".:;=@[\\]^`{|}", esc_Param, table); AddUnescapedChars("./:;=?@[\\]^`{|}", esc_Query, table); AddUnescapedChars("#'./:;=?@[\\]^{|}", esc_Ref, table);