diff --git a/url/setters_tests.json b/url/setters_tests.json index 8adb25ce977a8a4..6a2e8c8d5f765c0 100644 --- a/url/setters_tests.json +++ b/url/setters_tests.json @@ -346,6 +346,88 @@ } ], "host": [ + { + "comment": "Non-special scheme", + "href": "sc://x/", + "new_value": "\u0000", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, + { + "href": "sc://x/", + "new_value": "\u0009", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "\u000A", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "\u000D", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": " ", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, + { + "href": "sc://x/", + "new_value": "#", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "/", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "?", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "@", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, { "comment": "Cannot-be-a-base means no host", "href": "mailto:me@example.net", @@ -567,13 +649,13 @@ } }, { - "comment": "\\ is not a delimiter for non-special schemes, and it’s invalid in a domain", + "comment": "\\ is not a delimiter for non-special schemes", "href": "view-source+http://example.net/path", "new_value": "example.com\\stuff", "expected": { - "href": "view-source+http://example.net/path", - "host": "example.net", - "hostname": "example.net", + "href": "view-source+http://example.com\\stuff/path", + "host": "example.com\\stuff", + "hostname": "example.com\\stuff", "port": "" } }, @@ -680,6 +762,88 @@ } ], "hostname": [ + { + "comment": "Non-special scheme", + "href": "sc://x/", + "new_value": "\u0000", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, + { + "href": "sc://x/", + "new_value": "\u0009", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "\u000A", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "\u000D", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": " ", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, + { + "href": "sc://x/", + "new_value": "#", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "/", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "?", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } + }, + { + "href": "sc://x/", + "new_value": "@", + "expected": { + "href": "sc://x/", + "host": "x", + "hostname": "x" + } + }, { "comment": "Cannot-be-a-base means no host", "href": "mailto:me@example.net", @@ -824,13 +988,13 @@ } }, { - "comment": "\\ is not a delimiter for non-special schemes, and it’s invalid in a domain", + "comment": "\\ is not a delimiter for non-special schemes", "href": "view-source+http://example.net/path", "new_value": "example.com\\stuff", "expected": { - "href": "view-source+http://example.net/path", - "host": "example.net", - "hostname": "example.net", + "href": "view-source+http://example.com\\stuff/path", + "host": "example.com\\stuff", + "hostname": "example.com\\stuff", "port": "" } }, diff --git a/url/urltestdata.json b/url/urltestdata.json index 575793511490796..e87e93620e469c2 100644 --- a/url/urltestdata.json +++ b/url/urltestdata.json @@ -4256,22 +4256,82 @@ "search": "", "hash": "" }, - "# unknown schemes and non-ASCII domains", + "# unknown schemes and their hosts", { "input": "sc://ñ.test/", "base": "about:blank", - "href": "sc://xn--ida.test/", + "href": "sc://%C3%B1.test/", "origin": "null", "protocol": "sc:", "username": "", "password": "", - "host": "xn--ida.test", - "hostname": "xn--ida.test", + "host": "%C3%B1.test", + "hostname": "%C3%B1.test", "port": "", "pathname": "/", "search": "", "hash": "" }, + { + "input": "sc://\u001F!\"$%&'()*+,-.;<=>^_`{|}~/", + "base": "about:blank", + "href": "sc://%1F!\"$%&'()*+,-.;<=>^_`{|}~/", + "origin": "null", + "protocol": "sc:", + "username": "", + "password": "", + "host": "%1F!\"$%&'()*+,-.;<=>^_`{|}~", + "hostname": "%1F!\"$%&'()*+,-.;<=>^_`{|}~", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + { + "input": "sc://\u0000/", + "base": "about:blank", + "failure": true + }, + { + "input": "sc:// /", + "base": "about:blank", + "failure": true + }, + { + "input": "sc://@/", + "base": "about:blank", + "failure": true + }, + { + "input": "sc://te@s:t@/", + "base": "about:blank", + "failure": true + }, + { + "input": "sc://:/", + "base": "about:blank", + "failure": true + }, + { + "input": "sc://:12/", + "base": "about:blank", + "failure": true + }, + { + "input": "x", + "base": "sc://ñ", + "href": "sc://%C3%B1/x", + "origin": "null", + "protocol": "sc:", + "username": "", + "password": "", + "host": "%C3%B1", + "hostname": "%C3%B1", + "port": "", + "pathname": "/x", + "search": "", + "hash": "" + }, "# unknown schemes and backslashes", { "input": "sc:\\../", @@ -4754,5 +4814,16 @@ "pathname": "/", "search": "", "hash": "" + }, + "# Empty host", + { + "input": "http://?", + "base": "about:blank", + "failure": "true" + }, + { + "input": "http://#", + "base": "about:blank", + "failure": "true" } ]