mirror of
https://github.com/moparisthebest/k-9
synced 2024-08-13 17:03:48 -04:00
Catch IllegalCharsetNameException causing force-close on unsupported japanese charsets (issue 3272)
This commit is contained in:
parent
d5c865749d
commit
f2283aa91e
@ -14,6 +14,7 @@ import java.io.OutputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.IllegalCharsetNameException;
|
||||||
|
|
||||||
|
|
||||||
public class MimeUtility {
|
public class MimeUtility {
|
||||||
@ -1381,13 +1382,19 @@ public class MimeUtility {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* See if there is conversion from the MIME charset to the Java one.
|
* See if there is conversion from the MIME charset to the Java one.
|
||||||
|
* this function may also throw an exception if the charset name is not known
|
||||||
*/
|
*/
|
||||||
if (!Charset.isSupported(charset)) {
|
boolean supported;
|
||||||
|
try {
|
||||||
|
supported = Charset.isSupported(charset);
|
||||||
|
} catch (IllegalCharsetNameException e) {
|
||||||
|
supported = false;
|
||||||
|
}
|
||||||
|
if (!supported) {
|
||||||
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
|
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
|
||||||
". Falling back to US-ASCII");
|
". Falling back to US-ASCII");
|
||||||
charset = "US-ASCII";
|
charset = "US-ASCII";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert and return as new String
|
* Convert and return as new String
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user