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

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

fixes #246
Manish Goregaokar 9 лет назад
Родитель
Сommit
a3e8a6d54d
1 измененных файлов с 3 добавлено и 2 удалено
  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) {
-        while let Some(c) = input.next() {
+        while let Some((c, utf8_c)) = input.next_utf8() {
             if c ==  '\0' {
                 self.syntax_violation("NULL characters are ignored in URL fragment identifiers")
             } else {
                 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));
             }
         }
     }