Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trim [ and ] from host string before used to connect by TcpStream #1818

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sqlx-core/src/net/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub enum Socket {

impl Socket {
pub async fn connect_tcp(host: &str, port: u16) -> io::Result<Self> {
TcpStream::connect((host, port)).await.map(Socket::Tcp)
// Trim square brackets from host if it's an IPv6 address as the `url` crate doesn't do that.
TcpStream::connect((host.trim_matches(|c| c == '[' || c == ']'), port))
.await
.map(Socket::Tcp)
}

#[cfg(unix)]
Expand Down