@@ -79,6 +79,7 @@ macro_rules! simple_enum_error {
7979
8080simple_enum_error ! {
8181 EmptyHost => "empty host" ,
82+ InvalidAuthority => "invalid authority" ,
8283 IdnaError => "invalid international domain name" ,
8384 InvalidPort => "invalid port number" ,
8485 InvalidIpv4Address => "invalid IPv4 address" ,
@@ -890,7 +891,19 @@ impl<'a> Parser<'a> {
890891 }
891892 let ( mut userinfo_char_count, remaining) = match last_at {
892893 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+ }
894907 Some ( x) => x,
895908 } ;
896909
0 commit comments