SPR-7471 - Regression in redirect URL encoding
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3607 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
2578cf21a0
commit
2d3eeeb4ea
|
|
@ -208,13 +208,13 @@ public class RedirectView extends AbstractUrlBasedView {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
String encoding = getEncoding(request);
|
String encoding = getEncoding(request);
|
||||||
|
|
||||||
// Prepare target URL.
|
// Prepare target URL.
|
||||||
StringBuilder targetUrl = new StringBuilder();
|
StringBuilder targetUrl = new StringBuilder();
|
||||||
if (this.contextRelative && getUrl().startsWith("/")) {
|
if (this.contextRelative && getUrl().startsWith("/")) {
|
||||||
// Do not apply context path to relative URLs.
|
// Do not apply context path to relative URLs.
|
||||||
targetUrl.append(UriUtils.encodePath(request.getContextPath(), encoding));
|
targetUrl.append(UriUtils.encodePath(request.getContextPath(), encoding));
|
||||||
targetUrl.append(UriUtils.encodePath(getUrl(), encoding));
|
targetUrl.append(UriUtils.encodeUri(getUrl(), encoding));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
targetUrl.append(UriUtils.encodeUri(getUrl(), encoding));
|
targetUrl.append(UriUtils.encodeUri(getUrl(), encoding));
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,12 @@ public class RedirectViewTests {
|
||||||
String expectedUrlForEncoding = "http://url.somewhere.com/test.htm" + "?" + key + "=" + val + "#myAnchor";
|
String expectedUrlForEncoding = "http://url.somewhere.com/test.htm" + "?" + key + "=" + val + "#myAnchor";
|
||||||
doTest(model, url, false, expectedUrlForEncoding);
|
doTest(model, url, false, expectedUrlForEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextRelativeQueryParam() throws Exception {
|
||||||
|
String url = "/test.html?id=1";
|
||||||
|
doTest(new HashMap<String, Object>(), url, true, url);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void twoParams() throws Exception {
|
public void twoParams() throws Exception {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue