Bläddra i källkod

url: make gopher behave like unrecognized schemes

Per the change in https://github.com/web-platform-tests/wpt/pull/19770.
Dirkjan Ochtman 6 år sedan
förälder
incheckning
2f204d0037
4 ändrade filer med 3 tillägg och 110 borttagningar
  1. 1 1
      src/origin.rs
  2. 2 3
      src/parser.rs
  3. 0 16
      tests/setters_tests.json
  4. 0 90
      tests/urltestdata.json

+ 1 - 1
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(),

+ 2 - 3
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<u16> {
         "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 {

+ 0 - 16
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",

+ 0 - 90
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",