Skip to content

Commit 570fbce

Browse files
RaisinTenMylesBorins
authored andcommitted
url: forbid pipe in URL host
Fixes: #37862 PR-URL: #37877 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 5e15ae0 commit 570fbce

File tree

5 files changed

+67
-12
lines changed

5 files changed

+67
-12
lines changed

src/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ CHAR_TEST(8, IsForbiddenHostCodePoint,
208208
ch == ' ' || ch == '#' || ch == '%' || ch == '/' ||
209209
ch == ':' || ch == '?' || ch == '@' || ch == '[' ||
210210
ch == '<' || ch == '>' || ch == '\\' || ch == ']' ||
211-
ch == '^')
211+
ch == '^' || ch == '|')
212212

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

test/cctest/test_url.cc

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ TEST_F(URLTest, Simple2) {
4444
EXPECT_EQ(simple.fragment(), "fragment");
4545
}
4646

47+
TEST_F(URLTest, ForbiddenHostCodePoint) {
48+
URL error("https://exa|mple.org:81/a/b/c?query#fragment");
49+
EXPECT_TRUE(error.flags() & URL_FLAGS_FAILED);
50+
}
51+
4752
TEST_F(URLTest, NoBase1) {
4853
URL error("123noscheme");
4954
EXPECT_TRUE(error.flags() & URL_FLAGS_FAILED);

test/fixtures/wpt/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Last update:
2121
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
2222
- interfaces: https://github.com/web-platform-tests/wpt/tree/79fa4cf76e/interfaces
2323
- resources: https://github.com/web-platform-tests/wpt/tree/972ca5b669/resources
24-
- url: https://github.com/web-platform-tests/wpt/tree/33f2e3f2e7/url
24+
- url: https://github.com/web-platform-tests/wpt/tree/5eebfdb1f6/url
2525

2626
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
2727
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt

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

+59-9
Original file line numberDiff line numberDiff line change
@@ -4682,30 +4682,30 @@
46824682
},
46834683
"Allowed host code points",
46844684
{
4685-
"input": "http://\u001F!\"$&'()*+,-.;=_`{|}~/",
4685+
"input": "http://\u001F!\"$&'()*+,-.;=_`{}~/",
46864686
"base": "about:blank",
4687-
"href": "http://\u001F!\"$&'()*+,-.;=_`{|}~/",
4688-
"origin": "http://\u001F!\"$&'()*+,-.;=_`{|}~",
4687+
"href": "http://\u001F!\"$&'()*+,-.;=_`{}~/",
4688+
"origin": "http://\u001F!\"$&'()*+,-.;=_`{}~",
46894689
"protocol": "http:",
46904690
"username": "",
46914691
"password": "",
4692-
"host": "\u001F!\"$&'()*+,-.;=_`{|}~",
4693-
"hostname": "\u001F!\"$&'()*+,-.;=_`{|}~",
4692+
"host": "\u001F!\"$&'()*+,-.;=_`{}~",
4693+
"hostname": "\u001F!\"$&'()*+,-.;=_`{}~",
46944694
"port": "",
46954695
"pathname": "/",
46964696
"search": "",
46974697
"hash": ""
46984698
},
46994699
{
4700-
"input": "sc://\u001F!\"$&'()*+,-.;=_`{|}~/",
4700+
"input": "sc://\u001F!\"$&'()*+,-.;=_`{}~/",
47014701
"base": "about:blank",
4702-
"href": "sc://%1F!\"$&'()*+,-.;=_`{|}~/",
4702+
"href": "sc://%1F!\"$&'()*+,-.;=_`{}~/",
47034703
"origin": "null",
47044704
"protocol": "sc:",
47054705
"username": "",
47064706
"password": "",
4707-
"host": "%1F!\"$&'()*+,-.;=_`{|}~",
4708-
"hostname": "%1F!\"$&'()*+,-.;=_`{|}~",
4707+
"host": "%1F!\"$&'()*+,-.;=_`{}~",
4708+
"hostname": "%1F!\"$&'()*+,-.;=_`{}~",
47094709
"port": "",
47104710
"pathname": "/",
47114711
"search": "",
@@ -5202,6 +5202,56 @@
52025202
"search": "",
52035203
"hash": ""
52045204
},
5205+
{
5206+
"input": "file://%43%3A",
5207+
"base": "about:blank",
5208+
"failure": true
5209+
},
5210+
{
5211+
"input": "file://%43%7C",
5212+
"base": "about:blank",
5213+
"failure": true
5214+
},
5215+
{
5216+
"input": "file://%43|",
5217+
"base": "about:blank",
5218+
"failure": true
5219+
},
5220+
{
5221+
"input": "file://C%7C",
5222+
"base": "about:blank",
5223+
"failure": true
5224+
},
5225+
{
5226+
"input": "file://%43%7C/",
5227+
"base": "about:blank",
5228+
"failure": true
5229+
},
5230+
{
5231+
"input": "https://%43%7C/",
5232+
"base": "about:blank",
5233+
"failure": true
5234+
},
5235+
{
5236+
"input": "asdf://%43|/",
5237+
"base": "about:blank",
5238+
"failure": true
5239+
},
5240+
{
5241+
"input": "asdf://%43%7C/",
5242+
"base": "about:blank",
5243+
"href": "asdf://%43%7C/",
5244+
"origin": "null",
5245+
"protocol": "asdf:",
5246+
"username": "",
5247+
"password": "",
5248+
"host": "%43%7C",
5249+
"hostname": "%43%7C",
5250+
"port": "",
5251+
"pathname": "/",
5252+
"search": "",
5253+
"hash": ""
5254+
},
52055255
"# file URLs relative to other file URLs (via https://github.com/jsdom/whatwg-url/pull/60)",
52065256
{
52075257
"input": "pix/submit.gif",

test/fixtures/wpt/versions.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"path": "resources"
4545
},
4646
"url": {
47-
"commit": "33f2e3f2e759bd51ebf8e4b9a01b067bc8281c5c",
47+
"commit": "5eebfdb1f68059549b3efff380dd190bc6078266",
4848
"path": "url"
4949
}
5050
}

0 commit comments

Comments
 (0)