Parcourir la source

Percent-encode fragments based on https://github.com/whatwg/url/pull/169

fixes #246
Manish Goregaokar il y a 9 ans
Parent
commit
a3e8a6d54d
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      src/parser.rs

+ 3 - 2
src/parser.rs

@@ -1083,12 +1083,13 @@ impl<'a> Parser<'a> {
     }
     }
 
 
     pub fn parse_fragment(&mut self, mut input: Input) {
     pub fn parse_fragment(&mut self, mut input: Input) {
-        while let Some(c) = input.next() {
+        while let Some((c, utf8_c)) = input.next_utf8() {
             if c ==  '\0' {
             if c ==  '\0' {
                 self.syntax_violation("NULL characters are ignored in URL fragment identifiers")
                 self.syntax_violation("NULL characters are ignored in URL fragment identifiers")
             } else {
             } else {
                 self.check_url_code_point(c, &input);
                 self.check_url_code_point(c, &input);
-                self.serialization.push(c);  // No percent-encoding here.
+                self.serialization.extend(utf8_percent_encode(utf8_c,
+                                                              SIMPLE_ENCODE_SET));
             }
             }
         }
         }
     }
     }