Validate contextPath in RedirectView

Issue: SPR-16752
This commit is contained in:
Rossen Stoyanchev
2018-04-23 15:20:12 -04:00
parent e9a8a5065b
commit de18d96413
2 changed files with 24 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -172,9 +172,7 @@ public class RedirectViewTests {
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
given(mockProcessor.processUrl(request, "/path")).willReturn("/path?key=123");
rv.render(new ModelMap(), request, response);
verify(mockProcessor).processUrl(request, "/path");
}
@@ -196,9 +194,7 @@ public class RedirectViewTests {
rv.setUrl("/path");
given(mockProcessor.processUrl(request, "/path")).willReturn("/path?key=123");
rv.render(new ModelMap(), request, response);
verify(mockProcessor).processUrl(request, "/path");
}
finally {
@@ -206,9 +202,7 @@ public class RedirectViewTests {
}
}
// SPR-13693
@Test
@Test // SPR-13693
public void remoteHost() throws Exception {
RedirectView rv = new RedirectView();
@@ -224,6 +218,19 @@ public class RedirectViewTests {
}
@Test // SPR-16752
public void contextRelativeWithValidatedContextPath() throws Exception {
String url = "/myUrl";
this.request.setContextPath("//context");
this.response = new MockHttpServletResponse();
doTest(new HashMap<>(), url, true, "/context" + url);
this.request.setContextPath("///context");
this.response = new MockHttpServletResponse();
doTest(new HashMap<>(), url, true, "/context" + url);
}
@Test
public void emptyMap() throws Exception {
String url = "/myUrl";