Skip to content

Commit 5937812

Browse files
committed
url: percent-encode NULL bytes in fragments
Per the change in whatwg/url#486.
1 parent 2f204d0 commit 5937812

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,9 +1480,9 @@ impl<'a> Parser<'a> {
14801480
self.log_violation(SyntaxViolation::NullInFragment)
14811481
} else {
14821482
self.check_url_code_point(c, &input);
1483-
self.serialization
1484-
.extend(utf8_percent_encode(utf8_c, FRAGMENT));
14851483
}
1484+
self.serialization
1485+
.extend(utf8_percent_encode(utf8_c, FRAGMENT));
14861486
}
14871487
}
14881488

tests/setters_tests.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,15 +1800,6 @@
18001800
"hash": "#foo%60bar"
18011801
}
18021802
},
1803-
{
1804-
"comment": "Simple percent-encoding; nuls, tabs, and newlines are removed",
1805-
"href": "a:/",
1806-
"new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
1807-
"expected": {
1808-
"href": "a:/#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
1809-
"hash": "#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
1810-
}
1811-
},
18121803
{
18131804
"comment": "Bytes already percent-encoded are left as-is",
18141805
"href": "http://example.net",

tests/urltestdata.json

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6562,20 +6562,5 @@
65626562
"pathname": "/test-a-colon-slash-slash-b.html",
65636563
"search": "",
65646564
"hash": ""
6565-
},
6566-
"Null code point in fragment",
6567-
{
6568-
"input": "http://example.org/test?a#b\u0000c",
6569-
"base": "about:blank",
6570-
"href": "http://example.org/test?a#bc",
6571-
"protocol": "http:",
6572-
"username": "",
6573-
"password": "",
6574-
"host": "example.org",
6575-
"hostname": "example.org",
6576-
"port": "",
6577-
"pathname": "/test",
6578-
"search": "?a",
6579-
"hash": "#bc"
65806565
}
65816566
]

0 commit comments

Comments
 (0)