Author: simonetripodi
Date: Tue Mar 19 12:30:02 2013
New Revision: 1458245

URL: http://svn.apache.org/r1458245
Log:
no needs to specify always the offset and the length of the byte[] has to be 
decoded, since in this implementation there's always the need to decode the 
whole buffer

Modified:
    
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
    
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
    
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
    
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java

Modified: 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java?rev=1458245&r1=1458244&r2=1458245&view=diff
==============================================================================
--- 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
 (original)
+++ 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
 Tue Mar 19 12:30:02 2013
@@ -82,21 +82,19 @@ final class Base64Decoder {
      * whitespace characters will be ignored.
      *
      * @param data the buffer containing the Base64-encoded data
-     * @param off the start offset (zero-based)
-     * @param length the number of bytes to convert
      * @param out the output stream to hold the decoded bytes
      *
      * @return the number of bytes produced.
      */
-    public static int decode(byte[] data, int off, int length, OutputStream 
out) throws IOException {
+    public static int decode(byte[] data, OutputStream out) throws IOException 
{
         byte    b1, b2, b3, b4;
         int        outLen = 0;
 
-        if (data.length == 0 || length == 0) {
+        if (data.length == 0) {
             return outLen;
         }
 
-        int        end = off + length;
+        int        end = data.length;
 
         while (end > 0) {
             if (!ignore((char) data[end - 1])) {
@@ -106,7 +104,7 @@ final class Base64Decoder {
             end--;
         }
 
-        int  i = off;
+        int  i = 0;
         // CHECKSTYLE IGNORE MagicNumber FOR NEXT 1 LINE
         int  finish = end - 4; // last set of 4 bytes might include padding
 

Modified: 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
URL: 
http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java?rev=1458245&r1=1458244&r2=1458245&view=diff
==============================================================================
--- 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
 (original)
+++ 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
 Tue Mar 19 12:30:02 2013
@@ -243,9 +243,9 @@ public final class MimeUtility {
 
             // Base64 encoded?
             if (encoding.equals(BASE64_ENCODING_MARKER)) {
-                Base64Decoder.decode(encodedData, 0, encodedData.length, out);
+                Base64Decoder.decode(encodedData, out);
             } else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { // 
maybe quoted printable.
-                QuotedPrintableDecoder.decode(encodedData, 0, 
encodedData.length, out);
+                QuotedPrintableDecoder.decode(encodedData, out);
             } else {
                 throw new UnsupportedEncodingException("Unknown RFC 2047 
encoding: " + encoding);
             }

Modified: 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java?rev=1458245&r1=1458244&r2=1458245&view=diff
==============================================================================
--- 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
 (original)
+++ 
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
 Tue Mar 19 12:30:02 2013
@@ -63,14 +63,14 @@ final class QuotedPrintableDecoder {
      * Decode the encoded byte data writing it to the given output stream.
      *
      * @param data   The array of byte data to decode.
-     * @param off    Starting offset within the array.
-     * @param length The length of data to encode.
      * @param out    The output stream used to return the decoded data.
      *
      * @return the number of bytes produced.
      * @exception IOException
      */
-    public static int decode(byte[] data, int off, int length, OutputStream 
out) throws IOException {
+    public static int decode(byte[] data, OutputStream out) throws IOException 
{
+        int off = 0;
+        int length = data.length;
         int endOffset = off + length;
         int bytesWritten = 0;
 

Modified: 
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java?rev=1458245&r1=1458244&r2=1458245&view=diff
==============================================================================
--- 
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
 (original)
+++ 
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
 Tue Mar 19 12:30:02 2013
@@ -59,7 +59,7 @@ public final class Base64DecoderTestCase
 
         ByteArrayOutputStream out = new 
ByteArrayOutputStream(encoded.length());
         byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET);
-        Base64Decoder.decode(encodedData, 0, encodedData.length, out);
+        Base64Decoder.decode(encodedData, out);
         byte[] actual = out.toByteArray();
 
         assertArrayEquals(expected, actual);


Reply via email to