From 443321f9f4949cf74089fed09d4e9ebf849df87f Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Thu, 9 Sep 2021 08:53:33 -0700 Subject: [PATCH] URLPattern: Throw on more illegal hostname code points. As discussed in the mozilla standards-position issue on URLPattern: https://github.com/mozilla/standards-positions/issues/566 There are a number of URL encoding interop issues between browsers. Since URLPattern delegates to the URL parser for canonicalization it is also exposed to these interop issues. While fixing all of URL's interop issues is orthogonal to shipping URLPattern, we can at least prevent clearly illegal code points from being used in URLPattern. This will avoid increasing usage of these code points which will in turn make it slightly easier to fix the issue in the URL parser in the future. Bug: 1248061 Change-Id: I58a55e4206004a6cba727f19d537c5929ce16d43 --- urlpattern/resources/urlpatterntestdata.json | 68 ++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/urlpattern/resources/urlpatterntestdata.json b/urlpattern/resources/urlpatterntestdata.json index 6138b30cdf5e44..867611baddbb5a 100644 --- a/urlpattern/resources/urlpatterntestdata.json +++ b/urlpattern/resources/urlpatterntestdata.json @@ -2359,5 +2359,73 @@ "expected_match": { "protocol": { "input": "foobar", "groups": { "name": "foobar" }} } + }, + { + "pattern": [{ "hostname": "bad hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad#hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad%hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad/hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad\\:hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "badhostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad?hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad@hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad[hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad]hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad\\\\hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad^hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad|hostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad\nhostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad\rhostname" }], + "expected_obj": "error" + }, + { + "pattern": [{ "hostname": "bad\thostname" }], + "expected_obj": "error" } ]