Skip to content

Commit 1f289b7

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 84db06e commit 1f289b7

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
@@ -245,6 +245,17 @@ public void contextPathWithForwardedPrefixTrailingSlash() throws Exception {
245245
assertEquals("/prefix", actual);
246246
}
247247

248+
@Test
249+
public void contextPathPreserveEncoding() throws Exception {
250+
this.request.setContextPath("/app%20");
251+
this.request.setRequestURI("/app%20/path/");
252+
HttpServletRequest actual = filterAndGetWrappedRequest();
253+
254+
assertEquals("/app%20", actual.getContextPath());
255+
assertEquals("/app%20/path/", actual.getRequestURI());
256+
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString());
257+
}
258+
248259
@Test
249260
public void sendRedirectWithAbsolutePath() throws Exception {
250261
this.request.addHeader(X_FORWARDED_PROTO, "https");

0 commit comments

Comments
 (0)