Repository: struts Updated Branches: refs/heads/develop ae12bd765 -> 4fbfa3b8b refs/heads/feature/WW-4267-removes-defaults f2b52612b -> bd2a5ea8d
Uses URL class to check if location is path or full url Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/4b7d2e35 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/4b7d2e35 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/4b7d2e35 Branch: refs/heads/feature/WW-4267-removes-defaults Commit: 4b7d2e35d09225a7c8b3b410588131b692b2730f Parents: bcd61a0 Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Sun Mar 9 21:46:33 2014 +0100 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Sun Mar 9 21:46:33 2014 +0100 ---------------------------------------------------------------------- .../dispatcher/ServletRedirectResult.java | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/4b7d2e35/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java index abc69eb..038d8c3 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java @@ -37,6 +37,9 @@ import org.apache.struts2.views.util.UrlHelper; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URLConnection; import java.util.*; import static javax.servlet.http.HttpServletResponse.SC_FOUND; @@ -262,13 +265,19 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec } - private boolean isPathUrl(String url) { - // filter out "http:", "https:", "mailto:", "file:", "ftp:" - return !url.startsWith("http:") - && !url.startsWith("https:") - && !url.startsWith("mailto:") - && !url.startsWith("file:") - && !url.startsWith("ftp:"); + /** + * Checks if url is simple path or either full url + * + * @param url string + * @return true if it's just a path not a full url + */ + protected boolean isPathUrl(String url) { + try { + return URI.create(url).getScheme() == null; + } catch (IllegalArgumentException e) { + LOG.debug("[#0] isn't a valid URL", e, url); + return false; + } } /**