myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfreed...@apache.org
Subject svn commit: r1139019 - /myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Date Thu, 23 Jun 2011 17:59:17 GMT
Author: mfreedman
Date: Thu Jun 23 17:59:17 2011
New Revision: 1139019

URL: http://svn.apache.org/viewvc?rev=1139019&view=rev
Log:
PORTLETBRIDGE-215: EncodeResourceURL improperly recognizes non context path encoded urls as
being internal.

Modified:
    myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java

Modified: myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=1139019&r1=1139018&r2=1139019&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
(original)
+++ myfaces/portlet-bridge/core/branches/trunk_1.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
Thu Jun 23 17:59:17 2011
@@ -338,9 +338,14 @@ public class PortletExternalContextImpl
       }
 
     }
-    else if (url.startsWith("#") || isExternalURL(url) || isDirectLink(url))
+    else if (url.startsWith("#") || isAbsoluteURL(url))
     {
       return url;
+    }  
+    else if (isExternalURL(url) || isDirectLink(url))
+    {
+      // its not an absolute URL (or would have been handled in previous if) convert it into
one.
+      return getAbsoluteUrlFromPath(url);
     }
     else
     {
@@ -592,14 +597,18 @@ public class PortletExternalContextImpl
       getRequestMap().put(BridgeImpl.REDIRECT_VIEWPARAMS, params);
       FacesContext.getCurrentInstance().responseComplete();
     }
-    else if ((url.startsWith("#") || isExternalURL(url) || isDirectLink(url)))
+    else if (getPortletPhase() == Bridge.PortletPhase.ACTION_PHASE && (url.startsWith("#")
|| isAbsoluteURL(url)))
     {
-      if (getPortletPhase() == Bridge.PortletPhase.ACTION_PHASE)
-      {
-        ((ActionResponse) getResponse()).sendRedirect(url);
-        FacesContext.getCurrentInstance().responseComplete();
-      }
-    } else
+      ((ActionResponse) getResponse()).sendRedirect(url);
+      FacesContext.getCurrentInstance().responseComplete();
+
+    }
+    else if (getPortletPhase() == Bridge.PortletPhase.ACTION_PHASE && (isExternalURL(url)
|| isDirectLink(url)))
+    {
+      ((ActionResponse) getResponse()).sendRedirect(getAbsoluteUrlFromPath(url));
+      FacesContext.getCurrentInstance().responseComplete();
+    }
+    else
     {
       // is it an unencoded Faces URL -- process it.
       // recurse on redirect after calling encodeActionURL which will 
@@ -1649,6 +1658,24 @@ public class PortletExternalContextImpl
     }
     return null;
   }
+  
+  private String getAbsoluteUrlFromPath(String path)
+  {
+    if (isRelativePath(path))
+    {
+      path = getPathFromRelativePath(path);
+    }
+    
+    // now add the absolute portion:
+    StringBuffer sb = new StringBuffer(path.length() + 20);
+    return sb.append(mPortletRequest.getScheme())
+             .append("://")
+             .append(mPortletRequest.getServerName())
+             .append(":")
+             .append(mPortletRequest.getServerPort())
+             .append(path)
+             .toString();
+  }
 
   private String getViewIdFromPath(String url)
   {
@@ -1925,7 +1952,7 @@ public class PortletExternalContextImpl
   private boolean isExternalURL(String url)
   {
 
-    if (!isAbsoluteURL(url))
+    if (!isAbsoluteURL(url) && !url.startsWith("/"))
     {
       return false;
     }



Mime
View raw message