From 2cfdb63014d1158fd15eb1f798f6b1610c275271 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Mon, 7 Jun 2021 21:11:18 -0700 Subject: [PATCH] URL: Add some possible bugs seen in implementation Collected from: - https://github.com/nodejs/node/issues/36559 - https://bugs.webkit.org/show_bug.cgi?id=226136 - https://crbug.com/1212318 --- url/resources/setters_tests.json | 58 ++++++++++++++++++++++++++++++++ url/resources/urltestdata.json | 30 +++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/url/resources/setters_tests.json b/url/resources/setters_tests.json index 56bcae464a6f54..69c36d01536bdc 100644 --- a/url/resources/setters_tests.json +++ b/url/resources/setters_tests.json @@ -990,6 +990,26 @@ "hostname": "test", "port": "12" } + }, + { + "comment": "Leading / is not stripped", + "href": "http://example.com/", + "new_value": "///bad.com", + "expected": { + "href": "http://example.com/", + "host": "example.com", + "hostname": "example.com" + } + }, + { + "comment": "Leading / is not stripped", + "href": "sc://example.com/", + "new_value": "///bad.com", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } } ], "hostname": [ @@ -1345,6 +1365,26 @@ "hostname": "", "pathname": "//p" } + }, + { + "comment": "Leading / is not stripped", + "href": "http://example.com/", + "new_value": "///bad.com", + "expected": { + "href": "http://example.com/", + "host": "example.com", + "hostname": "example.com" + } + }, + { + "comment": "Leading / is not stripped", + "href": "sc://example.com/", + "new_value": "///bad.com", + "expected": { + "href": "sc:///", + "host": "", + "hostname": "" + } } ], "port": [ @@ -1667,6 +1707,24 @@ "pathname": "/%23" } }, + { + "comment": "? doesn't mess up encoding", + "href": "http://example.net", + "new_value": "/?é", + "expected": { + "href": "http://example.net/%3F%C3%A9", + "pathname": "/%3F%C3%A9" + } + }, + { + "comment": "# doesn't mess up encoding", + "href": "http://example.net", + "new_value": "/#é", + "expected": { + "href": "http://example.net/%23%C3%A9", + "pathname": "/%23%C3%A9" + } + }, { "comment": "File URLs and (back)slashes", "href": "file://monkey/", diff --git a/url/resources/urltestdata.json b/url/resources/urltestdata.json index 96c42d2284ebf7..d20e8482c193d0 100644 --- a/url/resources/urltestdata.json +++ b/url/resources/urltestdata.json @@ -539,6 +539,36 @@ "search": "", "hash": "" }, + { + "input": "\\x", + "base": "http://example.org/foo/bar", + "href": "http://example.org/x", + "origin": "http://example.org", + "protocol": "http:", + "username": "", + "password": "", + "host": "example.org", + "hostname": "example.org", + "port": "", + "pathname": "/x", + "search": "", + "hash": "" + }, + { + "input": "\\\\x\\hello", + "base": "http://example.org/foo/bar", + "href": "http://x/hello", + "origin": "http://x", + "protocol": "http:", + "username": "", + "password": "", + "host": "x", + "hostname": "x", + "port": "", + "pathname": "/hello", + "search": "", + "hash": "" + }, { "input": "::", "base": "http://example.org/foo/bar",