Kaynağa Gözat

Merge pull request #108 from frewsxcv/prevent-panic

Prevent parsing brackets from causing panic
Simon Sapin 11 yıl önce
ebeveyn
işleme
d8a7e906f1
2 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 5 0
      src/host.rs
  2. 4 0
      src/urltestdata.txt

+ 5 - 0
src/host.rs

@@ -101,6 +101,11 @@ impl Ipv6Address {
         let mut piece_pointer = 0;
         let mut compress_pointer = None;
         let mut i = 0;
+
+        if len < 2 {
+            return Err(ParseError::InvalidIpv6Address)
+        }
+
         if input[0] == b':' {
             if input[1] != b':' {
                 return Err(ParseError::InvalidIpv6Address)

+ 4 - 0
src/urltestdata.txt

@@ -267,6 +267,10 @@ http://Goo%20\sgoo%7C|.com
 # This should fail
 http://GOO\u00a0\u3000goo.com
 
+# This should fail
+http://[]
+http://[:]
+
 # Other types of space (no-break, zero-width, zero-width-no-break) are
 # name-prepped away to nothing.
 XFAIL http://GOO\u200b\u2060\ufeffgoo.com  s:http p:/ h:googoo.com