@@ -79,6 +79,7 @@ macro_rules! simple_enum_error {
79
79
80
80
simple_enum_error ! {
81
81
EmptyHost => "empty host" ,
82
+ InvalidAuthority => "invalid authority" ,
82
83
IdnaError => "invalid international domain name" ,
83
84
InvalidPort => "invalid port number" ,
84
85
InvalidIpv4Address => "invalid IPv4 address" ,
@@ -890,7 +891,19 @@ impl<'a> Parser<'a> {
890
891
}
891
892
let ( mut userinfo_char_count, remaining) = match last_at {
892
893
None => return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, input) ) ,
893
- Some ( ( 0 , remaining) ) => return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, remaining) ) ,
894
+ Some ( ( 0 , remaining) ) => {
895
+ // Otherwise, if one of the following is true
896
+ // c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
897
+ // url is special and c is U+005C (\)
898
+ // If @ flag is set and buffer is the empty string, validation error, return failure.
899
+ if let ( Some ( c) , _) = remaining. split_first ( ) {
900
+ if c == '/' || c == '?' || c == '#'
901
+ || scheme_type. is_special ( ) && c == '\\' {
902
+ return Err ( ParseError :: InvalidAuthority ) ;
903
+ }
904
+ }
905
+ return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, remaining) ) ;
906
+ }
894
907
Some ( x) => x,
895
908
} ;
896
909
0 commit comments