struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [2/5] git commit: Extends logic how protocol part of url is extracted
Date Wed, 19 Mar 2014 08:38:58 GMT
Extends logic how protocol part of url is extracted


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/1ca55b8a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/1ca55b8a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/1ca55b8a

Branch: refs/heads/develop
Commit: 1ca55b8a79cc118128391bddd3b776024def79f8
Parents: 4b7d2e3
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Sun Mar 9 21:57:58 2014 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Sun Mar 9 21:57:58 2014 +0100

----------------------------------------------------------------------
 .../dispatcher/ServletRedirectResult.java       | 26 +++++++++++++++++---
 1 file changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/1ca55b8a/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 038d8c3..9820295 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java
@@ -37,9 +37,8 @@ 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.MalformedURLException;
 import java.net.URI;
-import java.net.URLConnection;
 import java.util.*;
 
 import static javax.servlet.http.HttpServletResponse.SC_FOUND;
@@ -273,9 +272,28 @@ public class ServletRedirectResult extends StrutsResultSupport implements
Reflec
      */
     protected boolean isPathUrl(String url) {
         try {
-            return URI.create(url).getScheme() == null;
+            URI uri = URI.create(url);
+            if (uri.isAbsolute()) {
+                uri.toURL();
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("[#0] is full url, not a path", url);
+                }
+                return true;
+            } else {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("[#0] isn't absolute URI, assuming it's a path", url);
+                }
+                return false;
+            }
         } catch (IllegalArgumentException e) {
-            LOG.debug("[#0] isn't a valid URL", e, url);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("[#0] isn't a valid URL, assuming it's a path", e, url);
+            }
+            return false;
+        } catch (MalformedURLException e) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("[#0] isn't a valid URL, assuming it's a path", e, url);
+            }
             return false;
         }
     }


Mime
View raw message