From f0d1c7ea22d009a80838ac062f492732796fcbaf Mon Sep 17 00:00:00 2001 From: crowlkats Date: Fri, 28 Jan 2022 18:06:54 +0100 Subject: [PATCH 1/2] Forbid | in URL hosts --- url/src/host.rs | 2 ++ url/tests/urltestdata.json | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/url/src/host.rs b/url/src/host.rs index d0a559589..11811c80e 100644 --- a/url/src/host.rs +++ b/url/src/host.rs @@ -107,6 +107,7 @@ impl Host { | ']' | '^' | '\u{007F}' + | '|' ) }; @@ -146,6 +147,7 @@ impl Host { | '\\' | ']' | '^' + | '|' ) }; diff --git a/url/tests/urltestdata.json b/url/tests/urltestdata.json index 290932785..c1f424d99 100644 --- a/url/tests/urltestdata.json +++ b/url/tests/urltestdata.json @@ -4707,6 +4707,11 @@ "base": "about:blank", "failure": true }, + { + "input": "sc://a|b/", + "base": "about:blank", + "failure": true + }, "Forbidden host codepoints: tabs and newlines are removed during preprocessing", { "input": "foo://ho\u0009st/", @@ -4931,6 +4936,11 @@ "base": "about:blank", "failure": true }, + { + "input": "http://a|b/", + "base": "about:blank", + "failure": true + }, { "input": "http://a\u007Fb/", "base": "about:blank", @@ -5200,6 +5210,11 @@ "base": "about:blank", "failure": true }, + { + "input": "http://ho%7Cst/", + "base": "about:blank", + "failure": true + }, { "input": "http://ho%7Fst/", "base": "about:blank", @@ -5777,6 +5792,36 @@ "base": "about:blank", "failure": true }, + { + "input": "file://%43%7C", + "base": "about:blank", + "failure": true + }, + { + "input": "file://%43|", + "base": "about:blank", + "failure": true + }, + { + "input": "file://C%7C", + "base": "about:blank", + "failure": true + }, + { + "input": "file://%43%7C/", + "base": "about:blank", + "failure": true + }, + { + "input": "https://%43%7C/", + "base": "about:blank", + "failure": true + }, + { + "input": "asdf://%43|/", + "base": "about:blank", + "failure": true + }, { "input": "asdf://%43%7C/", "base": "about:blank", From 3dc30d18eb8798506e051d04ec13952227b3aefe Mon Sep 17 00:00:00 2001 From: crowlkats Date: Fri, 28 Jan 2022 18:46:52 +0100 Subject: [PATCH 2/2] fmt --- url/src/host.rs | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/url/src/host.rs b/url/src/host.rs index 11811c80e..c150dd997 100644 --- a/url/src/host.rs +++ b/url/src/host.rs @@ -90,25 +90,21 @@ impl Host { } let is_invalid_domain_char = |c| { - matches!( - c, - | '\0'..='\u{001F}' - | ' ' - | '#' - | '%' - | '/' - | ':' - | '<' - | '>' - | '?' - | '@' - | '[' - | '\\' - | ']' - | '^' - | '\u{007F}' - | '|' - ) + matches!(c, |'\0'..='\u{001F}'| ' ' + | '#' + | '%' + | '/' + | ':' + | '<' + | '>' + | '?' + | '@' + | '[' + | '\\' + | ']' + | '^' + | '\u{007F}' + | '|') }; if domain.find(is_invalid_domain_char).is_some() {