james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1482293 - /james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
Date Tue, 14 May 2013 10:49:34 GMT
Author: olegk
Date: Tue May 14 10:49:34 2013
New Revision: 1482293

URL: http://svn.apache.org/r1482293
Log:
Throw checked i/o exception instead of unchecked one in case of an unsupported / invalid charset
in body descriptor

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java?rev=1482293&r1=1482292&r2=1482293&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
Tue May 14 10:49:34 2013
@@ -23,15 +23,15 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
 import java.util.LinkedList;
 
 import org.apache.james.mime4j.Charsets;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.io.LineNumberInputStream;
+import org.apache.james.mime4j.util.CharsetUtil;
 
 /**
  * <p>
@@ -311,19 +311,20 @@ public class MimeTokenStream {
      * @see #getInputStream
      * @throws IllegalStateException {@link #getState()} returns an
      *   invalid value
-     * @throws UnsupportedCharsetException if there is no JVM support
+     * @throws UnsupportedEncodingException if there is no JVM support
      * for decoding the charset
-     * @throws IllegalCharsetNameException if the charset name specified
-     * in the mime type is illegal
      */
-    public Reader getReader() {
+    public Reader getReader() throws UnsupportedEncodingException {
         final BodyDescriptor bodyDescriptor = getBodyDescriptor();
         final String mimeCharset = bodyDescriptor.getCharset();
         final Charset charset;
         if (mimeCharset == null || "".equals(mimeCharset)) {
             charset = Charsets.US_ASCII;
         } else {
-            charset = Charset.forName(mimeCharset);
+            charset = CharsetUtil.lookup(mimeCharset);
+            if (charset == null) {
+                throw new UnsupportedEncodingException(mimeCharset);
+            }
         }
         final InputStream instream = getDecodedInputStream();
         return new InputStreamReader(instream, charset);



Mime
View raw message