Fix ForwardedHeaderFilter preserves semicolon content

Previously a requestURI that contained ';' would have the value incorrectly stripped out when using
ForwardedHeaderFilter.

This commit ensures that the ';' is preserved when using ForwardedHeaderFilter.

Issue: SPR-15428
This commit is contained in:
Rob Winch 2017-04-10 09:03:51 -05:00
parent 96bfe7d197
commit e92e65f8c3
2 changed files with 12 additions and 0 deletions

View File

@ -74,6 +74,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter {
public ForwardedHeaderFilter() {
this.pathHelper = new UrlPathHelper();
this.pathHelper.setUrlDecode(false);
this.pathHelper.setRemoveSemicolonContent(false);
}

View File

@ -169,6 +169,17 @@ public class ForwardedHeaderFilterTests {
assertEquals("/", actual.getRequestURI());
}
@Test
public void requestUriPreserveSemicolonContent() throws Exception {
this.request.setContextPath("");
this.request.setRequestURI("/path;a=b/with/semicolon");
HttpServletRequest actual = filterAndGetWrappedRequest();
assertEquals("", actual.getContextPath());
assertEquals("/path;a=b/with/semicolon", actual.getRequestURI());
assertEquals("http://localhost/path;a=b/with/semicolon", actual.getRequestURL().toString());
}
@Test
public void caseInsensitiveForwardedPrefix() throws Exception {
this.request = new MockHttpServletRequest() {