ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1154554 - in /webservices/commons/trunk/modules/axiom/modules/axiom-api/src: main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java
Date Sat, 06 Aug 2011 17:18:45 GMT
Author: veithen
Date: Sat Aug  6 17:18:45 2011
New Revision: 1154554

URL: http://svn.apache.org/viewvc?rev=1154554&view=rev
Log:
AXIOM-380: Correctly decode base64 containing whitespace.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java?rev=1154554&r1=1154553&r2=1154554&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/base64/AbstractBase64DecodingWriter.java
Sat Aug  6 17:18:45 2011
@@ -30,24 +30,14 @@ public abstract class AbstractBase64Deco
     private final byte[] out = new byte[3];
     private int rest; // Number of characters remaining in the in buffer
 
+    private static boolean isWhitespace(int c) {
+        return c <= 32 && (c == ' ' || c == '\n' || c == '\r' || c == '\t'); 
+    }
+    
     public final void write(char[] cbuf, int off, int len) throws IOException {
-        if (rest > 0) {
-            while (len > 0 && rest < 4) {
-                in[rest++] = cbuf[off++];
-                len--;
-            }
-            if (rest == 4) {
-                decode(in, 0);
-                rest = 0;
-            }
-        }
-        while (len >= 4) {
-            decode(cbuf, off);
-            off += 3;
-            len -= 3;
-        }
         while (len > 0) {
-            in[rest++] = cbuf[off++];
+            write(cbuf[off]);
+            off++;
             len--;
         }
     }
@@ -61,10 +51,12 @@ public abstract class AbstractBase64Deco
     }
 
     public final void write(int c) throws IOException {
-        in[rest++] = (char)c;
-        if (rest == 4) {
-            decode(in, 0);
-            rest = 0;
+        if (!isWhitespace(c)) {
+            in[rest++] = (char)c;
+            if (rest == 4) {
+                decode(in, 0);
+                rest = 0;
+            }
         }
     }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java?rev=1154554&r1=1154553&r2=1154554&view=diff
==============================================================================
Files webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java
(original) and webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/XMLStreamReaderUtilsTest.java
Sat Aug  6 17:18:45 2011 differ



Mime
View raw message