@@ -70,6 +70,7 @@ macro_rules! simple_enum_error {
70
70
71
71
simple_enum_error ! {
72
72
EmptyHost => "empty host" ,
73
+ InvalidAuthority => "invalid authority" ,
73
74
IdnaError => "invalid international domain name" ,
74
75
InvalidPort => "invalid port number" ,
75
76
InvalidIpv4Address => "invalid IPv4 address" ,
@@ -872,7 +873,19 @@ impl<'a> Parser<'a> {
872
873
}
873
874
let ( mut userinfo_char_count, remaining) = match last_at {
874
875
None => return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, input) ) ,
875
- Some ( ( 0 , remaining) ) => return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, remaining) ) ,
876
+ Some ( ( 0 , remaining) ) => {
877
+ // Otherwise, if one of the following is true
878
+ // c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#)
879
+ // url is special and c is U+005C (\)
880
+ // If @ flag is set and buffer is the empty string, validation error, return failure.
881
+ if let ( Some ( c) , _) = remaining. split_first ( ) {
882
+ if c == '/' || c == '?' || c == '#'
883
+ || scheme_type. is_special ( ) && c == '\\' {
884
+ return Err ( ParseError :: InvalidAuthority ) ;
885
+ }
886
+ }
887
+ return Ok ( ( to_u32 ( self . serialization . len ( ) ) ?, remaining) ) ;
888
+ }
876
889
Some ( x) => x,
877
890
} ;
878
891
0 commit comments