From bb8d885bc1be4b30272f6ea05394cf4a059323c5 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 10 Mar 2017 10:14:01 +0100 Subject: [PATCH 1/2] URL: protocol setter needs to be more restrictive for "file" See https://github.com/whatwg/url/issues/259. --- url/setters_tests.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/url/setters_tests.json b/url/setters_tests.json index dbe7f777733393..176f0ca94667b0 100644 --- a/url/setters_tests.json +++ b/url/setters_tests.json @@ -109,6 +109,31 @@ "protocol": "a:" } }, + { + "comment": "Can’t switch from URL containing username/password/port to file", + "href": "http://test@example.net", + "new_value": "file", + "expected": { + "href": "http://test@example.net/", + "protocol": "http:" + } + }, + { + "href": "gopher://example.net:1234", + "new_value": "file", + "expected": { + "href": "gopher://example.net:1234/", + "protocol": "gopher:" + } + }, + { + "href": "wss://x:x@example.net:1234", + "new_value": "file", + "expected": { + "href": "wss://x:x@example.net:1234/", + "protocol": "wss:" + } + }, { "comment": "Can’t switch from special scheme to non-special", "href": "http://example.net", @@ -168,6 +193,14 @@ "protocol": "ssh:" } }, + { + "href": "ssh://example.net", + "new_value": "file", + "expected": { + "href": "ssh://example.net", + "protocol": "ssh:" + } + }, { "href": "nonsense:///test", "new_value": "https", From 17966a23f1a561e5e0cd86232b3655c47240c9d5 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 10 Mar 2017 12:22:34 +0100 Subject: [PATCH 2/2] switching from file without host (impossible) --- url/setters_tests.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/url/setters_tests.json b/url/setters_tests.json index 176f0ca94667b0..96bbc549e9b56b 100644 --- a/url/setters_tests.json +++ b/url/setters_tests.json @@ -134,6 +134,31 @@ "protocol": "wss:" } }, + { + "comment": "Can’t switch from file URL with no host", + "href": "file://localhost/", + "new_value": "http", + "expected": { + "href": "file:///", + "protocol": "file:" + } + }, + { + "href": "file:///test", + "new_value": "gopher", + "expected": { + "href": "file:///test", + "protocol": "file:" + } + }, + { + "href": "file:", + "new_value": "wss", + "expected": { + "href": "file:///", + "protocol": "file:" + } + }, { "comment": "Can’t switch from special scheme to non-special", "href": "http://example.net", @@ -143,6 +168,14 @@ "protocol": "http:" } }, + { + "href": "file://hi/path", + "new_value": "s", + "expected": { + "href": "file://hi/path", + "protocol": "file:" + } + }, { "href": "https://example.net", "new_value": "s",