Skip to content

Commit 9d4d73f

Browse files
committed
url: restrict setting protocol to "file"
Since file URLs can not have `username/password/port`, the specification was updated to restrict setting protocol to "file". Refs: whatwg/url#269 Fixes: #11785
1 parent 5bfd13b commit 9d4d73f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/internal/url.js

+7
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ function onParseProtocolComplete(flags, protocol, username, password,
133133
if ((s && !newIsSpecial) || (!s && newIsSpecial)) {
134134
return;
135135
}
136+
if (protocol === 'file:' &&
137+
(ctx.username || ctx.password || ctx.port !== undefined)) {
138+
return;
139+
}
140+
if (ctx.scheme === 'file:' && !ctx.host) {
141+
return;
142+
}
136143
if (newIsSpecial) {
137144
ctx.flags |= binding.URL_FLAGS_SPECIAL;
138145
} else {

0 commit comments

Comments
 (0)