Skip to content

Commit 0a9f98f

Browse files
committed
Add test to ensure ForwardedHeaderFilter contextPath preserves encoding
Add a test to verify that the ForwardedHeaderFilter contextPath override preserves URL encoding as it should. Issue SPR-15422
1 parent 46cf4f9 commit 0a9f98f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ public void contextPathWithForwardedPrefixTrailingSlash() throws Exception {
249249
assertEquals("/prefix", actual);
250250
}
251251

252+
@Test
253+
public void contextPathPreserveEncoding() throws Exception {
254+
this.request.setContextPath("/app%20");
255+
this.request.setRequestURI("/app%20/path/");
256+
HttpServletRequest actual = filterAndGetWrappedRequest();
257+
258+
assertEquals("/app%20", actual.getContextPath());
259+
assertEquals("/app%20/path/", actual.getRequestURI());
260+
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString());
261+
}
262+
252263
@Test
253264
public void sendRedirectWithAbsolutePath() throws Exception {
254265
this.request.addHeader(X_FORWARDED_PROTO, "https");

0 commit comments

Comments
 (0)