mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8318130: SocksSocketImpl needlessly encodes hostname for IPv6 addresses
Reviewed-by: dfuchs, jpai, aefimov, michaelm
This commit is contained in:
parent
eb5916729d
commit
728b858c78
2 changed files with 203 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,6 +37,8 @@ import sun.net.SocksProxy;
|
|||
import sun.net.spi.DefaultProxySelector;
|
||||
import sun.net.www.ParseUtil;
|
||||
|
||||
import static sun.net.util.IPAddressUtil.isIPv6LiteralAddress;
|
||||
|
||||
/**
|
||||
* SOCKS (V4 & V5) TCP socket implementation (RFC 1928).
|
||||
*/
|
||||
|
@ -297,17 +299,15 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
|
|||
URI uri;
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
String host = epoint.getHostString();
|
||||
// IPv6 literal?
|
||||
if (epoint.getAddress() instanceof Inet6Address &&
|
||||
(!host.startsWith("[")) && (host.indexOf(':') >= 0)) {
|
||||
if (isIPv6LiteralAddress(host)) {
|
||||
host = "[" + host + "]";
|
||||
} else {
|
||||
host = ParseUtil.encodePath(host);
|
||||
}
|
||||
try {
|
||||
uri = new URI("socket://" + ParseUtil.encodePath(host) + ":"+ epoint.getPort());
|
||||
uri = new URI("socket://" + host + ":"+ epoint.getPort());
|
||||
} catch (URISyntaxException e) {
|
||||
// This shouldn't happen
|
||||
assert false : e;
|
||||
uri = null;
|
||||
throw new IOException("Failed to select a proxy", e);
|
||||
}
|
||||
Proxy p = null;
|
||||
IOException savedExc = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue