Merge branch 'jetty-9.4.x'

This commit is contained in:
Greg Wilkins 2017-06-06 16:57:44 +02:00
commit 829815be5e
1 changed files with 5 additions and 1 deletions

View File

@ -22,9 +22,13 @@ package org.eclipse.jetty.util;
* Parse an authority string into Host and Port
* <p>Parse a string in the form "host:port", handling IPv4 an IPv6 hosts</p>
*
* <p>The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean
* value to control of the square brackets are stripped off IPv6 addresses.</p>
*/
public class HostPort
{
private final static boolean STRIP_IPV6 = Boolean.parseBoolean(System.getProperty("org.eclipse.jetty.util.HostPort.STRIP_IPV6","true"));
private final String _host;
private final int _port;
@ -45,7 +49,7 @@ public class HostPort
int close=authority.lastIndexOf(']');
if (close<0)
throw new IllegalArgumentException("Bad IPv6 host");
_host=authority.substring(0,close+1);
_host=STRIP_IPV6?authority.substring(0,close+1):authority.substring(1,close);
if (authority.length()>close+1)
{