Check if scheme is localhost and fail

Fixes gh-2919
This commit is contained in:
sgibb
2024-03-12 02:21:15 -04:00
parent de105a1574
commit c6dbf0ef8e

View File

@@ -187,9 +187,11 @@ public class Route implements Ordered {
this.uri = uri;
String scheme = this.uri.getScheme();
Assert.hasText(scheme, "The parameter [" + this.uri + "] format is incorrect, scheme can not be empty");
if (!scheme.equalsIgnoreCase("forward")) {
Assert.hasText(this.uri.getHost(),
"The parameter [" + this.uri + "] format is incorrect, host can not be empty");
if (scheme.equalsIgnoreCase("localhost")) {
// common error
// TODO: find a general way to detect without breaking existing behavior
throw new IllegalArgumentException(
"The parameter [" + this.uri + "] format is incorrect, scheme can not be localhost");
}
if (this.uri.getPort() < 0 && scheme.startsWith("http")) {
// default known http ports