Merge branch '6.1.x'
This commit is contained in:
commit
1d2b55e670
|
|
@ -76,9 +76,9 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
|
|
||||||
private static final String HTTP_PATTERN = "(?i)(http|https):";
|
private static final String HTTP_PATTERN = "(?i)(http|https):";
|
||||||
|
|
||||||
private static final String USERINFO_PATTERN = "([^@/?#]*)";
|
private static final String USERINFO_PATTERN = "([^/?#]*)";
|
||||||
|
|
||||||
private static final String HOST_IPV4_PATTERN = "[^\\[/?#:]*";
|
private static final String HOST_IPV4_PATTERN = "[^/?#:]*";
|
||||||
|
|
||||||
private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]";
|
private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]";
|
||||||
|
|
||||||
|
|
@ -243,9 +243,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
builder.schemeSpecificPart(ssp);
|
builder.schemeSpecificPart(ssp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (StringUtils.hasLength(scheme) && scheme.startsWith("http") && !StringUtils.hasLength(host)) {
|
checkSchemeAndHost(uri, scheme, host);
|
||||||
throw new IllegalArgumentException("[" + uri + "] is not a valid HTTP URL");
|
|
||||||
}
|
|
||||||
builder.userInfo(userInfo);
|
builder.userInfo(userInfo);
|
||||||
builder.host(host);
|
builder.host(host);
|
||||||
if (StringUtils.hasLength(port)) {
|
if (StringUtils.hasLength(port)) {
|
||||||
|
|
@ -287,9 +285,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
builder.scheme(scheme != null ? scheme.toLowerCase() : null);
|
builder.scheme(scheme != null ? scheme.toLowerCase() : null);
|
||||||
builder.userInfo(matcher.group(4));
|
builder.userInfo(matcher.group(4));
|
||||||
String host = matcher.group(5);
|
String host = matcher.group(5);
|
||||||
if (StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) {
|
checkSchemeAndHost(httpUrl, scheme, host);
|
||||||
throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
|
|
||||||
}
|
|
||||||
builder.host(host);
|
builder.host(host);
|
||||||
String port = matcher.group(7);
|
String port = matcher.group(7);
|
||||||
if (StringUtils.hasLength(port)) {
|
if (StringUtils.hasLength(port)) {
|
||||||
|
|
@ -308,6 +304,15 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkSchemeAndHost(String uri, @Nullable String scheme, @Nullable String host) {
|
||||||
|
if (StringUtils.hasLength(scheme) && scheme.startsWith("http") && !StringUtils.hasLength(host)) {
|
||||||
|
throw new IllegalArgumentException("[" + uri + "] is not a valid HTTP URL");
|
||||||
|
}
|
||||||
|
if (StringUtils.hasLength(host) && host.startsWith("[") && !host.endsWith("]")) {
|
||||||
|
throw new IllegalArgumentException("Invalid IPV6 host in [" + uri + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code UriComponents} object from the URI associated with
|
* Create a new {@code UriComponents} object from the URI associated with
|
||||||
* the given HttpRequest while also overlaying with values from the headers
|
* the given HttpRequest while also overlaying with values from the headers
|
||||||
|
|
@ -363,6 +368,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||||
if (StringUtils.hasLength(port)) {
|
if (StringUtils.hasLength(port)) {
|
||||||
builder.port(port);
|
builder.port(port);
|
||||||
}
|
}
|
||||||
|
checkSchemeAndHost(origin, scheme, host);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue