Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 824978e

Browse filesBrowse files
jasnellItalo A. Casas
authored andcommitted
url: do not decode arbitrary %2e sequences in paths
Per a recent change to the URL spec, arbitrary %2e sequences in URL paths that are not single or double dot segments are not to be decoded. Refs: whatwg/url#87 Refs: whatwg/url#156 Refs: web-platform-tests/wpt@d93247d Fixes: #10598 PR-URL: #10602 Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent e46bdcf commit 824978e
Copy full SHA for 824978e

File tree

Expand file treeCollapse file tree

3 files changed

+12
-17
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-17
lines changed
Open diff view settings
Collapse file

‎src/node_url.cc‎

Copy file name to clipboardExpand all lines: src/node_url.cc
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,12 +1214,7 @@ namespace url {
12141214
state = kFragment;
12151215
}
12161216
} else {
1217-
if (ch == '%' && p[1] == '2' && TO_LOWER(p[2]) == 'e') {
1218-
buffer += '.';
1219-
p += 2;
1220-
} else {
1221-
AppendOrEscape(&buffer, ch, DefaultEncodeSet);
1222-
}
1217+
AppendOrEscape(&buffer, ch, DefaultEncodeSet);
12231218
}
12241219
break;
12251220
case kCannotBeBase:
Collapse file

‎test/fixtures/url-setter-tests.json‎

Copy file name to clipboardExpand all lines: test/fixtures/url-setter-tests.json
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@
953953
"href": "view-source+http://example.net/home?lang=fr#nav",
954954
"new_value": "\\a\\%2E\\b\\%2e.\\c",
955955
"expected": {
956-
"href": "view-source+http://example.net/\\a\\.\\b\\..\\c?lang=fr#nav",
957-
"pathname": "/\\a\\.\\b\\..\\c"
956+
"href": "view-source+http://example.net/\\a\\%2E\\b\\%2e.\\c?lang=fr#nav",
957+
"pathname": "/\\a\\%2E\\b\\%2e.\\c"
958958
}
959959
},
960960
{
@@ -967,12 +967,12 @@
967967
}
968968
},
969969
{
970-
"comment": "Bytes already percent-encoded are left as-is, except %2E.",
970+
"comment": "Bytes already percent-encoded are left as-is, including %2E outside dotted segments.",
971971
"href": "http://example.net",
972972
"new_value": "%2e%2E%c3%89té",
973973
"expected": {
974-
"href": "http://example.net/..%c3%89t%C3%A9",
975-
"pathname": "/..%c3%89t%C3%A9"
974+
"href": "http://example.net/%2e%2E%c3%89t%C3%A9",
975+
"pathname": "/%2e%2E%c3%89t%C3%A9"
976976
}
977977
},
978978
{
Collapse file

‎test/fixtures/url-tests.json‎

Copy file name to clipboardExpand all lines: test/fixtures/url-tests.json
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,30 +1847,30 @@
18471847
{
18481848
"input": "http://example.com/foo/%2e%2",
18491849
"base": "about:blank",
1850-
"href": "http://example.com/foo/.%2",
1850+
"href": "http://example.com/foo/%2e%2",
18511851
"origin": "http://example.com",
18521852
"protocol": "http:",
18531853
"username": "",
18541854
"password": "",
18551855
"host": "example.com",
18561856
"hostname": "example.com",
18571857
"port": "",
1858-
"pathname": "/foo/.%2",
1858+
"pathname": "/foo/%2e%2",
18591859
"search": "",
18601860
"hash": ""
18611861
},
18621862
{
18631863
"input": "http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar",
18641864
"base": "about:blank",
1865-
"href": "http://example.com/..bar",
1865+
"href": "http://example.com/%2e.bar",
18661866
"origin": "http://example.com",
18671867
"protocol": "http:",
18681868
"username": "",
18691869
"password": "",
18701870
"host": "example.com",
18711871
"hostname": "example.com",
18721872
"port": "",
1873-
"pathname": "/..bar",
1873+
"pathname": "/%2e.bar",
18741874
"search": "",
18751875
"hash": ""
18761876
},
@@ -2288,15 +2288,15 @@
22882288
{
22892289
"input": "http://www/foo%2Ehtml",
22902290
"base": "about:blank",
2291-
"href": "http://www/foo.html",
2291+
"href": "http://www/foo%2Ehtml",
22922292
"origin": "http://www",
22932293
"protocol": "http:",
22942294
"username": "",
22952295
"password": "",
22962296
"host": "www",
22972297
"hostname": "www",
22982298
"port": "",
2299-
"pathname": "/foo.html",
2299+
"pathname": "/foo%2Ehtml",
23002300
"search": "",
23012301
"hash": ""
23022302
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.