Skip to content

Commit 5b9dac3

Browse files
committed
url: forbid lt and gt in url host code point
As per the recent changes in whatwg/url spec. lt and gt are also added in the list of forbidden hostCodePoint list. Ref: whatwg/url#459 Ref: nodejs#33315
1 parent 8607f9e commit 5b9dac3

File tree

2 files changed

+64
-16
lines changed

2 files changed

+64
-16
lines changed

src/node_url.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ CHAR_TEST(8, IsForbiddenHostCodePoint,
206206
ch == '\0' || ch == '\t' || ch == '\n' || ch == '\r' ||
207207
ch == ' ' || ch == '#' || ch == '%' || ch == '/' ||
208208
ch == ':' || ch == '?' || ch == '@' || ch == '[' ||
209-
ch == '\\' || ch == ']')
209+
ch == '<' || ch == '>' || ch == '\\' || ch == ']' ||
210+
ch == '^')
210211

211212
// https://url.spec.whatwg.org/#windows-drive-letter
212213
TWO_CHAR_STRING_TEST(8, IsWindowsDriveLetter,

test/fixtures/wpt/url/resources/urltestdata.json

+62-15
Original file line numberDiff line numberDiff line change
@@ -4481,21 +4481,6 @@
44814481
"search": "",
44824482
"hash": ""
44834483
},
4484-
{
4485-
"input": "sc://\u001F!\"$&'()*+,-.;<=>^_`{|}~/",
4486-
"base": "about:blank",
4487-
"href": "sc://%1F!\"$&'()*+,-.;<=>^_`{|}~/",
4488-
"origin": "null",
4489-
"protocol": "sc:",
4490-
"username": "",
4491-
"password": "",
4492-
"host": "%1F!\"$&'()*+,-.;<=>^_`{|}~",
4493-
"hostname": "%1F!\"$&'()*+,-.;<=>^_`{|}~",
4494-
"port": "",
4495-
"pathname": "/",
4496-
"search": "",
4497-
"hash": ""
4498-
},
44994484
{
45004485
"input": "sc://\u0000/",
45014486
"base": "about:blank",
@@ -4649,6 +4634,68 @@
46494634
"search": "",
46504635
"hash": ""
46514636
},
4637+
"Forbidden host code points",
4638+
{
4639+
"input": "http://a<b",
4640+
"base": "about:blank",
4641+
"failure": true
4642+
},
4643+
{
4644+
"input": "http://a>b",
4645+
"base": "about:blank",
4646+
"failure": true
4647+
},
4648+
{
4649+
"input": "http://a^b",
4650+
"base": "about:blank",
4651+
"failure": true
4652+
},
4653+
{
4654+
"input": "non-special://a<b",
4655+
"base": "about:blank",
4656+
"failure": true
4657+
},
4658+
{
4659+
"input": "non-special://a>b",
4660+
"base": "about:blank",
4661+
"failure": true
4662+
},
4663+
{
4664+
"input": "non-special://a^b",
4665+
"base": "about:blank",
4666+
"failure": true
4667+
},
4668+
"Allowed host code points",
4669+
{
4670+
"input": "http://\u001F!\"$&'()*+,-.;=_`{|}~/",
4671+
"base": "about:blank",
4672+
"href": "http://\u001F!\"$&'()*+,-.;=_`{|}~/",
4673+
"origin": "http://\u001F!\"$&'()*+,-.;=_`{|}~",
4674+
"protocol": "http:",
4675+
"username": "",
4676+
"password": "",
4677+
"host": "\u001F!\"$&'()*+,-.;=_`{|}~",
4678+
"hostname": "\u001F!\"$&'()*+,-.;=_`{|}~",
4679+
"port": "",
4680+
"pathname": "/",
4681+
"search": "",
4682+
"hash": ""
4683+
},
4684+
{
4685+
"input": "sc://\u001F!\"$&'()*+,-.;=_`{|}~/",
4686+
"base": "about:blank",
4687+
"href": "sc://%1F!\"$&'()*+,-.;=_`{|}~/",
4688+
"origin": "null",
4689+
"protocol": "sc:",
4690+
"username": "",
4691+
"password": "",
4692+
"host": "%1F!\"$&'()*+,-.;=_`{|}~",
4693+
"hostname": "%1F!\"$&'()*+,-.;=_`{|}~",
4694+
"port": "",
4695+
"pathname": "/",
4696+
"search": "",
4697+
"hash": ""
4698+
},
46524699
"# Hosts and percent-encoding",
46534700
{
46544701
"input": "ftp://example.com%80/",

0 commit comments

Comments
 (0)