File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ impl Authority {
5050 . expect ( "static str is not valid authority" )
5151 }
5252
53-
5453 /// Attempt to convert a `Bytes` buffer to a `Authority`.
5554 ///
5655 /// This will try to prevent a copy if the type passed is the type used
@@ -91,13 +90,16 @@ impl Authority {
9190 colon_cnt += 1 ;
9291 }
9392 b'[' => {
94- start_bracket = true ;
95- if has_percent {
93+ if has_percent || start_bracket {
9694 // Something other than the userinfo has a `%`, so reject it.
9795 return Err ( ErrorKind :: InvalidAuthority . into ( ) ) ;
9896 }
97+ start_bracket = true ;
9998 }
10099 b']' => {
100+ if end_bracket {
101+ return Err ( ErrorKind :: InvalidAuthority . into ( ) ) ;
102+ }
101103 end_bracket = true ;
102104
103105 // Those were part of an IPv6 hostname, so forget them...
@@ -642,4 +644,10 @@ mod tests {
642644 . unwrap_err ( ) ;
643645 assert_eq ! ( err. 0 , ErrorKind :: InvalidUriChar ) ;
644646 }
647+
648+ #[ test]
649+ fn rejects_invalid_use_of_brackets ( ) {
650+ let err = Authority :: parse_non_empty ( b"[]@[" ) . unwrap_err ( ) ;
651+ assert_eq ! ( err. 0 , ErrorKind :: InvalidAuthority ) ;
652+ }
645653}
You can’t perform that action at this time.
0 commit comments