From 85461d41b2f92db680a6195f79c7291ef11fa46c Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Wed, 21 Mar 2018 11:47:08 -0400 Subject: [PATCH] Checks path for encoding as well as query. fixes gh-233 --- .../filter/RouteToRequestUrlFilter.java | 4 ++-- .../factory/HystrixGatewayFilterFactory.java | 4 ++-- .../support/ServerWebExchangeUtils.java | 9 ++++---- .../filter/RouteToRequestUrlFilterTests.java | 22 +++++++++++++++++++ ...estParameterGatewayFilterFactoryTests.java | 4 ++-- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/RouteToRequestUrlFilter.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/RouteToRequestUrlFilter.java index 361131aff..fd8795174 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/RouteToRequestUrlFilter.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/RouteToRequestUrlFilter.java @@ -30,7 +30,7 @@ import org.springframework.web.util.UriComponentsBuilder; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedQuery; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts; import reactor.core.publisher.Mono; @@ -58,7 +58,7 @@ public class RouteToRequestUrlFilter implements GlobalFilter, Ordered { } log.trace("RouteToRequestUrlFilter start"); URI uri = exchange.getRequest().getURI(); - boolean encoded = containsEncodedQuery(uri); + boolean encoded = containsEncodedParts(uri); URI routeUri = route.getUri(); if (hasAnotherScheme(routeUri)) { diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/HystrixGatewayFilterFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/HystrixGatewayFilterFactory.java index bbbd97b6e..c5be7b7f2 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/HystrixGatewayFilterFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/HystrixGatewayFilterFactory.java @@ -38,7 +38,7 @@ import com.netflix.hystrix.exception.HystrixRuntimeException; import static com.netflix.hystrix.exception.HystrixRuntimeException.FailureType.TIMEOUT; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedQuery; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.setResponseStatus; import reactor.core.publisher.Mono; @@ -123,7 +123,7 @@ public class HystrixGatewayFilterFactory extends AbstractGatewayFilterFactory