From 2f204d0037882d742c4f9c6660356967982219d6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 10 Aug 2020 15:46:59 +0200 Subject: [PATCH] url: make gopher behave like unrecognized schemes Per the change in https://github.com/web-platform-tests/wpt/pull/19770. --- src/origin.rs | 2 +- src/parser.rs | 5 +-- tests/setters_tests.json | 16 ------- tests/urltestdata.json | 90 ---------------------------------------- 4 files changed, 3 insertions(+), 110 deletions(-) diff --git a/src/origin.rs b/src/origin.rs index 3223709dd..cc4cf980f 100644 --- a/src/origin.rs +++ b/src/origin.rs @@ -22,7 +22,7 @@ pub fn url_origin(url: &Url) -> Origin { Err(_) => Origin::new_opaque(), } } - "ftp" | "gopher" | "http" | "https" | "ws" | "wss" => Origin::Tuple( + "ftp" | "http" | "https" | "ws" | "wss" => Origin::Tuple( scheme.to_owned(), url.host().unwrap().to_owned(), url.port_or_known_default().unwrap(), diff --git a/src/parser.rs b/src/parser.rs index 317d276b3..02d6060ff 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -174,7 +174,7 @@ impl SchemeType { pub fn from(s: &str) -> Self { match s { - "http" | "https" | "ws" | "wss" | "ftp" | "gopher" => SchemeType::SpecialNotFile, + "http" | "https" | "ws" | "wss" | "ftp" => SchemeType::SpecialNotFile, "file" => SchemeType::File, _ => SchemeType::NotSpecial, } @@ -186,7 +186,6 @@ pub fn default_port(scheme: &str) -> Option { "http" | "ws" => Some(80), "https" | "wss" => Some(443), "ftp" => Some(21), - "gopher" => Some(70), _ => None, } } @@ -1438,7 +1437,7 @@ impl<'a> Parser<'a> { } let encoding = match &self.serialization[..scheme_end as usize] { - "http" | "https" | "file" | "ftp" | "gopher" => self.query_encoding_override, + "http" | "https" | "file" | "ftp" => self.query_encoding_override, _ => None, }; let query_bytes = if let Some(o) = encoding { diff --git a/tests/setters_tests.json b/tests/setters_tests.json index 3df1991f1..118632e4d 100644 --- a/tests/setters_tests.json +++ b/tests/setters_tests.json @@ -118,14 +118,6 @@ "protocol": "http:" } }, - { - "href": "gopher://example.net:1234", - "new_value": "file", - "expected": { - "href": "gopher://example.net:1234/", - "protocol": "gopher:" - } - }, { "href": "wss://x:x@example.net:1234", "new_value": "file", @@ -210,14 +202,6 @@ "protocol": "ssh:" } }, - { - "href": "ssh://me@example.net", - "new_value": "gopher", - "expected": { - "href": "ssh://me@example.net", - "protocol": "ssh:" - } - }, { "href": "ssh://me@example.net", "new_value": "file", diff --git a/tests/urltestdata.json b/tests/urltestdata.json index 09e4df59b..90f089cca 100644 --- a/tests/urltestdata.json +++ b/tests/urltestdata.json @@ -1073,21 +1073,6 @@ "search": "", "hash": "" }, - { - "input": "gopher:/example.com/", - "base": "http://example.org/foo/bar", - "href": "gopher://example.com/", - "origin": "gopher://example.com", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "example.com", - "hostname": "example.com", - "port": "", - "pathname": "/", - "search": "", - "hash": "" - }, { "input": "ws:/example.com/", "base": "http://example.org/foo/bar", @@ -1238,21 +1223,6 @@ "search": "", "hash": "" }, - { - "input": "gopher:example.com/", - "base": "http://example.org/foo/bar", - "href": "gopher://example.com/", - "origin": "gopher://example.com", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "example.com", - "hostname": "example.com", - "port": "", - "pathname": "/", - "search": "", - "hash": "" - }, { "input": "ws:example.com/", "base": "http://example.org/foo/bar", @@ -2508,36 +2478,6 @@ "search": "", "hash": "" }, - { - "input": "gopher://foo:70/", - "base": "about:blank", - "href": "gopher://foo/", - "origin": "gopher://foo", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "foo", - "hostname": "foo", - "port": "", - "pathname": "/", - "search": "", - "hash": "" - }, - { - "input": "gopher://foo:443/", - "base": "about:blank", - "href": "gopher://foo:443/", - "origin": "gopher://foo:443", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "foo:443", - "hostname": "foo", - "port": "443", - "pathname": "/", - "search": "", - "hash": "" - }, { "input": "ws://foo:80/", "base": "about:blank", @@ -2747,21 +2687,6 @@ "search": "", "hash": "" }, - { - "input": "gopher:/example.com/", - "base": "about:blank", - "href": "gopher://example.com/", - "origin": "gopher://example.com", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "example.com", - "hostname": "example.com", - "port": "", - "pathname": "/", - "search": "", - "hash": "" - }, { "input": "ws:/example.com/", "base": "about:blank", @@ -2912,21 +2837,6 @@ "search": "", "hash": "" }, - { - "input": "gopher:example.com/", - "base": "about:blank", - "href": "gopher://example.com/", - "origin": "gopher://example.com", - "protocol": "gopher:", - "username": "", - "password": "", - "host": "example.com", - "hostname": "example.com", - "port": "", - "pathname": "/", - "search": "", - "hash": "" - }, { "input": "ws:example.com/", "base": "about:blank",