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
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/fileupload/trunk@1458245 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
index 0f5369b..9d205e7 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
@@ -82,21 +82,19 @@
* 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 @@
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
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
index dbbd4f1..f6f6231 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/MimeUtility.java
@@ -243,9 +243,9 @@
// 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);
}
diff --git a/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java b/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
index da3c087..de61cc7 100644
--- a/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
+++ b/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
@@ -63,14 +63,14 @@
* 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;
diff --git a/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java b/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
index 8ab0f8c..68eff8e 100644
--- a/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
+++ b/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
@@ -59,7 +59,7 @@
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);