From b9f27772e618503fdec5ec7ef2e6d978f632117c Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Fri, 10 Sep 2021 08:40:34 -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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152036 Reviewed-by: Jeremy Roman Commit-Queue: Ben Kelly Cr-Commit-Position: refs/heads/main@{#920223} --- 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" } ]