Browse Source

SPR-7471 - Regression in redirect URL encoding

3.0.x
Arjen Poutsma 16 years ago
parent
commit
001d676dec
  1. 4
      org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java
  2. 6
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java

4
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java

@ -208,13 +208,13 @@ public class RedirectView extends AbstractUrlBasedView { @@ -208,13 +208,13 @@ public class RedirectView extends AbstractUrlBasedView {
throws IOException {
String encoding = getEncoding(request);
// Prepare target URL.
StringBuilder targetUrl = new StringBuilder();
if (this.contextRelative && getUrl().startsWith("/")) {
// Do not apply context path to relative URLs.
targetUrl.append(UriUtils.encodePath(request.getContextPath(), encoding));
targetUrl.append(UriUtils.encodePath(getUrl(), encoding));
targetUrl.append(UriUtils.encodeUri(getUrl(), encoding));
}
else {
targetUrl.append(UriUtils.encodeUri(getUrl(), encoding));

6
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java

@ -135,6 +135,12 @@ public class RedirectViewTests { @@ -135,6 +135,12 @@ public class RedirectViewTests {
String expectedUrlForEncoding = "http://url.somewhere.com/test.htm" + "?" + key + "=" + val + "#myAnchor";
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
public void twoParams() throws Exception {

Loading…
Cancel
Save