Skip to content

Commit

Permalink
url: restrict setting protocol to "file"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
watilde authored and MylesBorins committed Mar 28, 2017
1 parent 8ab26cf commit c51d925
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ function onParseProtocolComplete(flags, protocol, username, password,
if ((s && !newIsSpecial) || (!s && newIsSpecial)) {
return;
}
if (protocol === 'file:' &&
(ctx.username || ctx.password || ctx.port !== undefined)) {
return;
}
if (ctx.scheme === 'file:' && !ctx.host) {
return;
}
if (newIsSpecial) {
ctx.flags |= binding.URL_FLAGS_SPECIAL;
} else {
Expand Down

0 comments on commit c51d925

Please sign in to comment.