You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/09/19 05:48:27 UTC

svn commit: r447715 - /myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java

Author: mmarinschek
Date: Mon Sep 18 20:48:27 2006
New Revision: 447715

URL: http://svn.apache.org/viewvc?view=rev&rev=447715
Log:
fix for TOMAHAWK-660: resources fail in web apps with spaces in context path

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java?view=diff&rev=447715&r1=447714&r2=447715
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/StreamingAddResource.java Mon Sep 18 20:48:27 2006
@@ -17,6 +17,7 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -24,6 +25,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.net.URLEncoder;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
@@ -721,6 +723,22 @@
         {
             path = RESOURCE_VIRTUAL_PATH;
         }
+
+        //fix for TOMAHAWK-660; to be sure this fix is backwards compatible, the
+        //encoded context-path is only used as a first option to check for the prefix
+        //if we're sure this works for all cases, we can directly return the first value
+        //and not double-check.
+        try
+        {
+            if(request.getRequestURI().startsWith(URLEncoder.encode(path,"UTF-8")))
+                return true;
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            log.error("Unsupported encoding UTF-8 used",e);
+
+        }
+
         return request.getRequestURI().startsWith(path);
     }