File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -309,13 +309,13 @@ fn get_authority(rawurl: &str) ->
309
309
colon_count = 0 ; // reset count
310
310
match st {
311
311
State :: Start => {
312
- let user = rawurl[ begin..i] . to_string ( ) ;
312
+ let user = try! ( decode_component ( & rawurl[ begin..i] ) ) ;
313
313
userinfo = Some ( UserInfo :: new ( user, None ) ) ;
314
314
st = State :: InHost ;
315
315
}
316
316
State :: PassHostPort => {
317
- let user = rawurl[ begin..pos] . to_string ( ) ;
318
- let pass = rawurl[ pos+1 ..i] . to_string ( ) ;
317
+ let user = try! ( decode_component ( & rawurl[ begin..pos] ) ) ;
318
+ let pass = try! ( decode_component ( & rawurl[ pos+1 ..i] ) ) ;
319
319
userinfo = Some ( UserInfo :: new ( user, Some ( pass) ) ) ;
320
320
st = State :: InHost ;
321
321
}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ use postgres::{HandleNotice,
17
17
Error ,
18
18
ConnectError ,
19
19
DbError ,
20
+ IntoConnectParams ,
20
21
VecStreamIterator } ;
21
22
use postgres:: SqlState :: { SyntaxError ,
22
23
QueryCanceled ,
@@ -936,3 +937,10 @@ fn test_get_opt_wrong_type() {
936
937
Err ( e) => panic ! ( "unexpected error {}" , e) ,
937
938
}
938
939
}
940
+
941
+ #[ test]
942
+ fn url_encoded_password ( ) {
943
+ let params = "postgresql://username%7b%7c:password%7b%7c@localhost" . into_connect_params ( ) . unwrap ( ) ;
944
+ assert_eq ! ( "username{|" , & params. user. as_ref( ) . unwrap( ) . user[ ..] ) ;
945
+ assert_eq ! ( "password{|" , & params. user. as_ref( ) . unwrap( ) . password. as_ref( ) . unwrap( ) [ ..] ) ;
946
+ }
You can’t perform that action at this time.
0 commit comments