You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/04/01 15:42:45 UTC

svn commit: r929970 - /felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java

Author: rickhall
Date: Thu Apr  1 13:42:45 2010
New Revision: 929970

URL: http://svn.apache.org/viewvc?rev=929970&view=rev
Log:
Backport FELIX-2195 to framework 2.0.5.

Modified:
    felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java

Modified: felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java?rev=929970&r1=929969&r2=929970&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java (original)
+++ felix/branches/org.apache.felix.framework-2.0.5-RC/src/main/java/org/apache/felix/framework/cache/BundleArchive.java Thu Apr  1 13:42:45 2010
@@ -156,7 +156,7 @@ public class BundleArchive
      * </p>
      * @param logger the logger to be used by the archive.
      * @param archiveRootDir the archive root directory for storing state.
-     * @param id the bundle identifier associated with the archive.
+     * @param configMap configMap for BundleArchive
      * @throws Exception if any error occurs.
     **/
     public BundleArchive(Logger logger, Map configMap, File archiveRootDir)
@@ -985,7 +985,7 @@ public class BundleArchive
                 }
 
                 // Decode any URL escaped sequences.
-                location = URLDecoder.decode(location, "UTF-8");
+                location = decode(location);
 
                 // Make sure the referenced file exists.
                 File file = new File(location.substring(FILE_PROTOCOL.length()));
@@ -1040,6 +1040,47 @@ public class BundleArchive
         return result;
     }
 
+    // Method from Harmony java.net.URIEncoderDecoder (luni subproject)
+    // used by URI to decode uri components.
+    private static String decode(String s) throws UnsupportedEncodingException
+    {
+        StringBuffer result = new StringBuffer();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        for (int i = 0; i < s.length(); )
+        {
+            char c = s.charAt(i);
+            if (c == '%')
+            {
+                out.reset();
+                do
+                {
+                    if (i + 2 >= s.length())
+                    {
+                        throw new IllegalArgumentException(
+                            "Incomplete % sequence at: " + i);
+                    }
+                    int d1 = Character.digit(s.charAt(i + 1), 16);
+                    int d2 = Character.digit(s.charAt(i + 2), 16);
+                    if ((d1 == -1) || (d2 == -1))
+                    {
+                        throw new IllegalArgumentException(
+                            "Invalid % sequence ("
+                            + s.substring(i, i + 3)
+                            + ") at: " + String.valueOf(i));
+                    }
+                    out.write((byte) ((d1 << 4) + d2));
+                    i += 3;
+                }
+                while ((i < s.length()) && (s.charAt(i) == '%'));
+                result.append(out.toString("UTF8"));
+                continue;
+            }
+            result.append(c);
+            i++;
+        }
+        return result.toString();
+    }
+
     /**
      * This utility method is used to retrieve the current refresh
      * counter value for the bundle. This value is used when generating