Skip to content

Commit c51d925

Browse files
watildeMylesBorins
authored andcommitted
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 PR-URL: #11887 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 8ab26cf commit c51d925

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
@@ -122,6 +122,13 @@ function onParseProtocolComplete(flags, protocol, username, password,
122122
if ((s && !newIsSpecial) || (!s && newIsSpecial)) {
123123
return;
124124
}
125+
if (protocol === 'file:' &&
126+
(ctx.username || ctx.password || ctx.port !== undefined)) {
127+
return;
128+
}
129+
if (ctx.scheme === 'file:' && !ctx.host) {
130+
return;
131+
}
125132
if (newIsSpecial) {
126133
ctx.flags |= binding.URL_FLAGS_SPECIAL;
127134
} else {

0 commit comments

Comments
 (0)