jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r454417 - in /jackrabbit/trunk/jackrabbit/src: main/java/org/apache/jackrabbit/util/ISO9075.java test/java/org/apache/jackrabbit/util/ISO9075Test.java
Date Mon, 09 Oct 2006 16:22:20 GMT
Author: jukka
Date: Mon Oct  9 09:22:18 2006
New Revision: 454417

URL: http://svn.apache.org/viewvc?view=rev&rev=454417
Log:
JCR-563: Avoid problems with decoding _x0024_ ($) and _x005c_ (\).

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/ISO9075.java
    jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/ISO9075.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/ISO9075.java?view=diff&rev=454417&r1=454416&r2=454417
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/ISO9075.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/ISO9075.java Mon
Oct  9 09:22:18 2006
@@ -134,7 +134,12 @@
         StringBuffer decoded = new StringBuffer();
         Matcher m = ENCODE_PATTERN.matcher(name);
         while (m.find()) {
-            m.appendReplacement(decoded, Character.toString((char) Integer.parseInt(m.group().substring(2,
6), 16)));
+            char ch = (char) Integer.parseInt(m.group().substring(2, 6), 16);
+            if (ch == '$' || ch == '\\') {
+                m.appendReplacement(decoded, "\\" + ch);
+            } else {
+                m.appendReplacement(decoded, Character.toString(ch));
+            }
         }
         m.appendTail(decoded);
         return decoded.toString();

Modified: jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java?view=diff&rev=454417&r1=454416&r2=454417
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/test/java/org/apache/jackrabbit/util/ISO9075Test.java
Mon Oct  9 09:22:18 2006
@@ -37,6 +37,21 @@
         assertEquals("My_x005f_x0020_x0020_Documents", ISO9075.encode("My_x0020 Documents"));
     }
 
+    public void testMatcherEscapes() {
+        assertEquals(
+                "StringWith$inside", ISO9075.decode("StringWith$inside"));
+        assertEquals(
+                "StringWith$inside", ISO9075.decode("StringWith_x0024_inside"));
+        assertEquals(
+                "StringWith_x0024_inside", ISO9075.encode("StringWith$inside"));
+        assertEquals(
+                "StringWith\\inside", ISO9075.decode("StringWith\\inside"));
+        assertEquals(
+                "StringWith\\inside", ISO9075.decode("StringWith_x005c_inside"));
+        assertEquals(
+                "StringWith_x005c_inside", ISO9075.encode("StringWith\\inside"));
+    }
+
     /**
      * This is a disabled brute force test. It tests permutations of characters:
      * <code>' ', '_', 'x', '0', '2', 'a', 'b', '{'</code>, encodes and decodes



Mime
View raw message