mirror of
https://github.com/apache/struts.git
synced 2026-08-31 11:24:28 +00:00
WW-4448 Strips params and replaces spaces
This commit is contained in:
@@ -272,7 +272,11 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
|
||||
*/
|
||||
protected boolean isPathUrl(String url) {
|
||||
try {
|
||||
URI uri = URI.create(url);
|
||||
String rawUrl = url;
|
||||
if (url.contains("?")) {
|
||||
rawUrl = url.substring(0, url.indexOf("?"));
|
||||
}
|
||||
URI uri = URI.create(rawUrl);
|
||||
if (uri.isAbsolute()) {
|
||||
URL validUrl = uri.toURL();
|
||||
if (LOG.isDebugEnabled()) {
|
||||
|
||||
@@ -100,6 +100,36 @@ public class ServletRedirectResultTest extends StrutsInternalTestCase implements
|
||||
}
|
||||
}
|
||||
|
||||
public void testFullUrlRedirectWithSpaces() {
|
||||
view.setLocation("http://localhost/bar/foo some.pdf");
|
||||
responseMock.expectAndReturn("encodeRedirectURL", C.args(C.eq("http://localhost/bar/foo some.pdf")), "http://localhost/bar/foo some.pdf");
|
||||
responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo some.pdf")));
|
||||
|
||||
try {
|
||||
view.execute(ai);
|
||||
requestMock.verify();
|
||||
responseMock.verify();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
public void testFullUrlRedirectWithParams() {
|
||||
view.setLocation("http://localhost/bar/foo.action?param=1¶m 2=3");
|
||||
responseMock.expectAndReturn("encodeRedirectURL", C.args(C.eq("http://localhost/bar/foo.action?param=1¶m 2=3")), "http://localhost/bar/foo.action?param=1¶m 2=3");
|
||||
responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo.action?param=1¶m 2=3")));
|
||||
|
||||
try {
|
||||
view.execute(ai);
|
||||
requestMock.verify();
|
||||
responseMock.verify();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
public void testAbsoluteRedirect303() {
|
||||
view.setLocation("/bar/foo.jsp");
|
||||
view.setStatusCode(303);
|
||||
|
||||
Reference in New Issue
Block a user