InetEndpoint: properly match IPv6 addresses

The old one didn't account for trailing digits.

Reported-by: Brandon Jackson <bjackson@napshome.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2019-03-19 00:53:14 -06:00
parent c4ba48d7a9
commit 76305045db

View File

@ -26,7 +26,7 @@ import java9.util.Optional;
* Instances of this class are externally immutable. * Instances of this class are externally immutable.
*/ */
public final class InetEndpoint { public final class InetEndpoint {
private static final Pattern BARE_IPV6 = Pattern.compile("^[^\\[]*:"); private static final Pattern BARE_IPV6 = Pattern.compile("^[^\\[\\]]*:[^\\[\\]]*");
private static final Pattern FORBIDDEN_CHARACTERS = Pattern.compile("[/?#]"); private static final Pattern FORBIDDEN_CHARACTERS = Pattern.compile("[/?#]");
private final String host; private final String host;