Author: markt
Date: Wed Mar 20 10:30:46 2013
New Revision: 1458726
URL: http://svn.apache.org/r1458726
Log:
The JRE (since Java 6) ships with a perfectly good Base64 Encoder/Decoder. Use
it.
Removed:
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/Base64Decoder.java
Modified:
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
Modified:
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java?rev=1458726&r1=1458725&r2=1458726&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/mime/MimeUtility.java
Wed Mar 20 10:30:46 2013
@@ -23,6 +23,8 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import javax.xml.bind.DatatypeConverter;
+
/**
* Utility class to decode MIME texts.
*
@@ -239,18 +241,18 @@ public final class MimeUtility {
// the decoder writes directly to an output stream.
ByteArrayOutputStream out = new
ByteArrayOutputStream(encodedText.length());
- byte[] encodedData = encodedText.getBytes(US_ASCII_CHARSET);
-
+ byte[] decodedData;
// Base64 encoded?
if (encoding.equals(BASE64_ENCODING_MARKER)) {
- Base64Decoder.decode(encodedData, out);
+ decodedData = DatatypeConverter.parseBase64Binary(encodedText);
} else if (encoding.equals(QUOTEDPRINTABLE_ENCODING_MARKER)) { //
maybe quoted printable.
+ byte[] encodedData = encodedText.getBytes(US_ASCII_CHARSET);
QuotedPrintableDecoder.decode(encodedData, out);
+ decodedData = out.toByteArray();
} else {
throw new UnsupportedEncodingException("Unknown RFC 2047
encoding: " + encoding);
}
- // get the decoded byte data and convert into a string.
- byte[] decodedData = out.toByteArray();
+ // Convert decoded byte data into a string.
return new String(decodedData, javaCharset(charset));
} catch (IOException e) {
throw new UnsupportedEncodingException("Invalid RFC 2047
encoding");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]