File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,8 +131,17 @@ fn decode_inner(c: &str, full_url: bool) -> DecodeResult<String> {
131131 }
132132 } ;
133133
134+ let bytes_from_hex = match Vec :: < u8 > :: from_hex ( & bytes) {
135+ Ok ( b) => b,
136+ _ => {
137+ return Err ( "Malformed input: found '%' followed by \
138+ invalid hex values. Character '%' must \
139+ escaped.". to_owned ( ) )
140+ }
141+ } ;
142+
134143 // Only decode some characters if full_url:
135- match Vec :: < u8 > :: from_hex ( & bytes ) . unwrap ( ) [ 0 ] as char {
144+ match bytes_from_hex [ 0 ] as char {
136145 // gen-delims:
137146 ':' |
138147 '/' |
Original file line number Diff line number Diff line change @@ -938,6 +938,11 @@ fn test_get_opt_wrong_type() {
938938 }
939939}
940940
941+ #[ test]
942+ fn url_unencoded_password ( ) {
943+ assert ! ( "postgresql://username:password%1*@localhost" . into_connect_params( ) . is_err( ) )
944+ }
945+
941946#[ test]
942947fn url_encoded_password ( ) {
943948 let params = "postgresql://username%7b%7c:password%7b%7c@localhost" . into_connect_params ( ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments