Skip to content

Commit cb0662b

Browse files
chromium-wpt-export-botannevk
authored andcommitted
Encode ' ', '"', '<', '>', and '`' in URL fragments
Implements the changes to fragment processing described in whatwg/url#347, which adds a new "fragment percent-encode set" which contains the C0 control percent-encode set, along with: * 0x20 SPACE * 0x22 (") * 0x3C (<) * 0x3E (>) * 0x60 (`)
1 parent 9641706 commit cb0662b

File tree

2 files changed

+114
-10
lines changed

2 files changed

+114
-10
lines changed

url/setters_tests.json

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,13 +1785,53 @@
17851785
"hash": ""
17861786
}
17871787
},
1788+
{
1789+
"href": "http://example.net",
1790+
"new_value": "#foo bar",
1791+
"expected": {
1792+
"href": "http://example.net/#foo%20bar",
1793+
"hash": "#foo%20bar"
1794+
}
1795+
},
1796+
{
1797+
"href": "http://example.net",
1798+
"new_value": "#foo\"bar",
1799+
"expected": {
1800+
"href": "http://example.net/#foo%22bar",
1801+
"hash": "#foo%22bar"
1802+
}
1803+
},
1804+
{
1805+
"href": "http://example.net",
1806+
"new_value": "#foo<bar",
1807+
"expected": {
1808+
"href": "http://example.net/#foo%3Cbar",
1809+
"hash": "#foo%3Cbar"
1810+
}
1811+
},
1812+
{
1813+
"href": "http://example.net",
1814+
"new_value": "#foo>bar",
1815+
"expected": {
1816+
"href": "http://example.net/#foo%3Ebar",
1817+
"hash": "#foo%3Ebar"
1818+
}
1819+
},
1820+
{
1821+
"href": "http://example.net",
1822+
"new_value": "#foo`bar",
1823+
"expected": {
1824+
"href": "http://example.net/#foo%60bar",
1825+
"hash": "#foo%60bar"
1826+
}
1827+
},
17881828
{
17891829
"comment": "Simple percent-encoding; nuls, tabs, and newlines are removed",
17901830
"href": "a:/",
17911831
"new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
17921832
"expected": {
1793-
"href": "a:/#%01%1F !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
1794-
"hash": "#%01%1F !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
1833+
"href": "a:/#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
1834+
"hash": "#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
17951835
}
17961836
},
17971837
{

url/urltestdata.json

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
{
154154
"input": "http://f:21/ b ? d # e ",
155155
"base": "http://example.org/foo/bar",
156-
"href": "http://f:21/%20b%20?%20d%20# e",
156+
"href": "http://f:21/%20b%20?%20d%20#%20e",
157157
"origin": "http://f:21",
158158
"protocol": "http:",
159159
"username": "",
@@ -163,12 +163,12 @@
163163
"port": "21",
164164
"pathname": "/%20b%20",
165165
"search": "?%20d%20",
166-
"hash": "# e"
166+
"hash": "#%20e"
167167
},
168168
{
169169
"input": "lolscheme:x x#x x",
170170
"base": "about:blank",
171-
"href": "lolscheme:x x#x x",
171+
"href": "lolscheme:x x#x%20x",
172172
"protocol": "lolscheme:",
173173
"username": "",
174174
"password": "",
@@ -177,7 +177,7 @@
177177
"port": "",
178178
"pathname": "x x",
179179
"search": "",
180-
"hash": "#x x"
180+
"hash": "#x%20x"
181181
},
182182
{
183183
"input": "http://f:/c",
@@ -2260,7 +2260,7 @@
22602260
{
22612261
"input": "http://www.google.com/foo?bar=baz# »",
22622262
"base": "about:blank",
2263-
"href": "http://www.google.com/foo?bar=baz# %C2%BB",
2263+
"href": "http://www.google.com/foo?bar=baz#%20%C2%BB",
22642264
"origin": "http://www.google.com",
22652265
"protocol": "http:",
22662266
"username": "",
@@ -2270,12 +2270,12 @@
22702270
"port": "",
22712271
"pathname": "/foo",
22722272
"search": "?bar=baz",
2273-
"hash": "# %C2%BB"
2273+
"hash": "#%20%C2%BB"
22742274
},
22752275
{
22762276
"input": "data:test# »",
22772277
"base": "about:blank",
2278-
"href": "data:test# %C2%BB",
2278+
"href": "data:test#%20%C2%BB",
22792279
"origin": "null",
22802280
"protocol": "data:",
22812281
"username": "",
@@ -2285,7 +2285,7 @@
22852285
"port": "",
22862286
"pathname": "test",
22872287
"search": "",
2288-
"hash": "# %C2%BB"
2288+
"hash": "#%20%C2%BB"
22892289
},
22902290
{
22912291
"input": "http://www.google.com",
@@ -4787,6 +4787,70 @@
47874787
"searchParams": "qux=",
47884788
"hash": "#foo%08bar"
47894789
},
4790+
{
4791+
"input": "http://foo.bar/baz?qux#foo\"bar",
4792+
"base": "about:blank",
4793+
"href": "http://foo.bar/baz?qux#foo%22bar",
4794+
"origin": "http://foo.bar",
4795+
"protocol": "http:",
4796+
"username": "",
4797+
"password": "",
4798+
"host": "foo.bar",
4799+
"hostname": "foo.bar",
4800+
"port": "",
4801+
"pathname": "/baz",
4802+
"search": "?qux",
4803+
"searchParams": "qux=",
4804+
"hash": "#foo%22bar"
4805+
},
4806+
{
4807+
"input": "http://foo.bar/baz?qux#foo<bar",
4808+
"base": "about:blank",
4809+
"href": "http://foo.bar/baz?qux#foo%3Cbar",
4810+
"origin": "http://foo.bar",
4811+
"protocol": "http:",
4812+
"username": "",
4813+
"password": "",
4814+
"host": "foo.bar",
4815+
"hostname": "foo.bar",
4816+
"port": "",
4817+
"pathname": "/baz",
4818+
"search": "?qux",
4819+
"searchParams": "qux=",
4820+
"hash": "#foo%3Cbar"
4821+
},
4822+
{
4823+
"input": "http://foo.bar/baz?qux#foo>bar",
4824+
"base": "about:blank",
4825+
"href": "http://foo.bar/baz?qux#foo%3Ebar",
4826+
"origin": "http://foo.bar",
4827+
"protocol": "http:",
4828+
"username": "",
4829+
"password": "",
4830+
"host": "foo.bar",
4831+
"hostname": "foo.bar",
4832+
"port": "",
4833+
"pathname": "/baz",
4834+
"search": "?qux",
4835+
"searchParams": "qux=",
4836+
"hash": "#foo%3Ebar"
4837+
},
4838+
{
4839+
"input": "http://foo.bar/baz?qux#foo`bar",
4840+
"base": "about:blank",
4841+
"href": "http://foo.bar/baz?qux#foo%60bar",
4842+
"origin": "http://foo.bar",
4843+
"protocol": "http:",
4844+
"username": "",
4845+
"password": "",
4846+
"host": "foo.bar",
4847+
"hostname": "foo.bar",
4848+
"port": "",
4849+
"pathname": "/baz",
4850+
"search": "?qux",
4851+
"searchParams": "qux=",
4852+
"hash": "#foo%60bar"
4853+
},
47904854
"# IPv4 parsing (via https://github.com/nodejs/node/pull/10317)",
47914855
{
47924856
"input": "http://192.168.257",

0 commit comments

Comments
 (0)