ForwardedHeaderTransformer handles encoding correctly

Issue: SPR-17525
This commit is contained in:
Rossen Stoyanchev
2018-11-21 11:17:10 -05:00
parent 97dac8a45d
commit 567fcc41cc
2 changed files with 14 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ import org.junit.Test;
import reactor.core.publisher.Mono;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
import org.springframework.mock.web.test.server.MockServerWebExchange;
@@ -113,6 +114,18 @@ public class ForwardedHeaderFilterTests {
assertEquals(new URI("http://example.com/prefix/path"), uri);
}
@Test // SPR-17525
public void shouldNotDoubleEncode() throws Exception {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest
.method(HttpMethod.GET, new URI ("http://example.com/a%20b?q=a%2Bb"))
.header("Forwarded", "host=84.198.58.199;proto=https"));
this.filter.filter(exchange, this.filterChain).block(Duration.ZERO);
URI uri = this.filterChain.uri;
assertEquals(new URI("https://84.198.58.199/a%20b?q=a%2Bb"), uri);
}
private static class TestWebFilterChain implements WebFilterChain {