mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user