WW-3879 Changes logic when the location is path and when full url address

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1390692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2012-09-26 19:27:41 +00:00
parent b84a1a9e9c
commit 2cf6cf5bcf
2 changed files with 20 additions and 4 deletions
@@ -250,11 +250,13 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec
}
private static boolean isPathUrl(String url) {
private boolean isPathUrl(String url) {
// filter out "http:", "https:", "mailto:", "file:", "ftp:"
// since the only valid places for : in URL's is before the path specification
// either before the port, or after the protocol
return (url.indexOf(':') == -1);
return !url.startsWith("http:")
&& !url.startsWith("https:")
&& !url.startsWith("mailto:")
&& !url.startsWith("file:")
&& !url.startsWith("ftp:");
}
/**
@@ -79,6 +79,20 @@ public class ServletRedirectResultTest extends StrutsTestCase implements StrutsS
}
}
public void testFullUrlRedirect() {
view.setLocation("http://localhost/bar/foo.jsp");
responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo.jsp")));
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);