Просмотр исходного кода

url: percent-encode NULL bytes in fragments

Per the change in https://github.com/whatwg/url/pull/486.
Dirkjan Ochtman 6 лет назад
Родитель
Сommit
5937812281
3 измененных файлов с 2 добавлено и 26 удалено
  1. 2 2
      src/parser.rs
  2. 0 9
      tests/setters_tests.json
  3. 0 15
      tests/urltestdata.json

+ 2 - 2
src/parser.rs

@@ -1480,9 +1480,9 @@ impl<'a> Parser<'a> {
                 self.log_violation(SyntaxViolation::NullInFragment)
                 self.log_violation(SyntaxViolation::NullInFragment)
             } else {
             } else {
                 self.check_url_code_point(c, &input);
                 self.check_url_code_point(c, &input);
-                self.serialization
-                    .extend(utf8_percent_encode(utf8_c, FRAGMENT));
             }
             }
+            self.serialization
+                .extend(utf8_percent_encode(utf8_c, FRAGMENT));
         }
         }
     }
     }
 
 

+ 0 - 9
tests/setters_tests.json

@@ -1800,15 +1800,6 @@
                 "hash": "#foo%60bar"
                 "hash": "#foo%60bar"
             }
             }
         },
         },
-        {
-            "comment": "Simple percent-encoding; nuls, tabs, and newlines are removed",
-            "href": "a:/",
-            "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
-            "expected": {
-                "href": "a:/#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
-                "hash": "#%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
-            }
-        },
         {
         {
             "comment": "Bytes already percent-encoded are left as-is",
             "comment": "Bytes already percent-encoded are left as-is",
             "href": "http://example.net",
             "href": "http://example.net",

+ 0 - 15
tests/urltestdata.json

@@ -6562,20 +6562,5 @@
     "pathname": "/test-a-colon-slash-slash-b.html",
     "pathname": "/test-a-colon-slash-slash-b.html",
     "search": "",
     "search": "",
     "hash": ""
     "hash": ""
-  },
-  "Null code point in fragment",
-  {
-    "input": "http://example.org/test?a#b\u0000c",
-    "base": "about:blank",
-    "href": "http://example.org/test?a#bc",
-    "protocol": "http:",
-    "username": "",
-    "password": "",
-    "host": "example.org",
-    "hostname": "example.org",
-    "port": "",
-    "pathname": "/test",
-    "search": "?a",
-    "hash": "#bc"
   }
   }
 ]
 ]