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: nodejs#11785
PR-URL: nodejs#11887
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
watilde authored and jungx098 committed Mar 21, 2017
1 parent c05bf36 commit 361e65f
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 @@ -133,6 +133,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 361e65f

Please sign in to comment.