jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1039423 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src: main/java/org/apache/jackrabbit/util/Base64.java test/java/org/apache/jackrabbit/util/Base64Test.java
Date Fri, 26 Nov 2010 15:41:00 GMT
Author: jukka
Date: Fri Nov 26 15:41:00 2010
New Revision: 1039423

URL: http://svn.apache.org/viewvc?rev=1039423&view=rev
Log:
JCR-2812: Allow whitespaces in base64 encoded binary fields of XML import files

Fix based on a patch by Berry van Halderen

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java?rev=1039423&r1=1039422&r2=1039423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Base64.java
Fri Nov 26 15:41:00 2010
@@ -278,7 +278,7 @@ public class Base64 {
                     }
                     posChunk = 0;
                 }
-            } else {
+            } else if (!Character.isWhitespace(c)) {
                 throw new IllegalArgumentException("specified data is not base64 encoded");
             }
         }

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java?rev=1039423&r1=1039422&r2=1039423&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/Base64Test.java
Fri Nov 26 15:41:00 2010
@@ -39,6 +39,16 @@ public class Base64Test extends TestCase
     }
 
     /**
+     * Tests that whitespace characters are ignored within base64 data.
+     */
+    public void testWhitespace() throws Exception {
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        Base64.decode(" d G\tV \tzdA\n= =\n", buffer);
+        byte[] data = buffer.toByteArray();
+        assertEquals("test", new String(data, "US-ASCII"));
+    }
+
+    /**
      * Tests that base 64 encoding/decoding round trips are lossless.
      */
     public void testBase64() throws Exception {



Mime
View raw message