Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d78e7a0d authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Switch from the incomplete (but compatible with java 1.3) mime4j charset

alias resolver to the core java nio version with a better charset
database;

rather than falling back to not showing the user a failing message, fall
back to showing the user the message as ascii -- it makes it possible
to get _something_ out of an unknown-charset message, rather than just a
"ha ha. no." error.
parent 7fc921c0
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.decoder.Base64InputStream;
import org.apache.james.mime4j.decoder.DecoderUtil;
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.CharsetUtil;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -17,6 +16,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.regex.Pattern;
import java.nio.charset.Charset;


public class MimeUtility
{
@@ -373,11 +374,12 @@ public class MimeUtility
                        /*
                         * See if there is conversion from the MIME charset to the Java one.
                         */
                        charset = CharsetUtil.toJavaCharset(originalCharset);
                        charset = Charset.forName(originalCharset).name();

                        if (charset == null)
                        {
                            return String.format(K9.app.getString(R.string.charset_not_found), originalCharset);
                            Log.e(K9.LOG_TAG,"I don't know how to deal with the charset "+originalCharset+". Falling back to US-ASCII");
                            charset = "US-ASCII";
                        }
                    }