mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(ext/fetch): percent decode userinfo when parsing proxies (#25229)
Fixes #24691
This commit is contained in:
parent
9fad717c29
commit
27edafa2fe
1 changed files with 14 additions and 1 deletions
|
@ -23,6 +23,7 @@ use hyper_util::client::legacy::connect::Connected;
|
|||
use hyper_util::client::legacy::connect::Connection;
|
||||
use hyper_util::rt::TokioIo;
|
||||
use ipnet::IpNet;
|
||||
use percent_encoding::percent_decode_str;
|
||||
use tokio::net::TcpStream;
|
||||
use tokio_rustls::client::TlsStream;
|
||||
use tokio_rustls::TlsConnector;
|
||||
|
@ -192,10 +193,12 @@ impl Target {
|
|||
|
||||
if let Some((userinfo, host_port)) = authority.as_str().split_once('@') {
|
||||
let (user, pass) = userinfo.split_once(':')?;
|
||||
let user = percent_decode_str(user).decode_utf8_lossy();
|
||||
let pass = percent_decode_str(pass).decode_utf8_lossy();
|
||||
if is_socks {
|
||||
socks_auth = Some((user.into(), pass.into()));
|
||||
} else {
|
||||
http_auth = Some(basic_auth(user, Some(pass)));
|
||||
http_auth = Some(basic_auth(&user, Some(&pass)));
|
||||
}
|
||||
builder = builder.authority(host_port);
|
||||
} else {
|
||||
|
@ -773,6 +776,16 @@ fn test_proxy_parse_from_env() {
|
|||
_ => panic!("bad target"),
|
||||
}
|
||||
|
||||
// percent encoded user info
|
||||
match parse("us%2Fer:p%2Fass@127.0.0.1:6666") {
|
||||
Target::Http { dst, auth } => {
|
||||
assert_eq!(dst, "http://127.0.0.1:6666");
|
||||
let auth = auth.unwrap();
|
||||
assert_eq!(auth.to_str().unwrap(), "Basic dXMvZXI6cC9hc3M=");
|
||||
}
|
||||
_ => panic!("bad target"),
|
||||
}
|
||||
|
||||
// socks
|
||||
match parse("socks5://user:pass@127.0.0.1:6666") {
|
||||
Target::Socks { dst, auth } => {
|
||||
|
|
Loading…
Reference in a new issue