Catch IllegalCharsetNameException causing force-close on unsupported japanese charsets (issue 3272)
This commit is contained in:
parent
d5c865749d
commit
f2283aa91e
1 changed files with 9 additions and 2 deletions
|
@ -14,6 +14,7 @@ import java.io.OutputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
|
||||
|
||||
public class MimeUtility {
|
||||
|
@ -1381,13 +1382,19 @@ public class MimeUtility {
|
|||
|
||||
/*
|
||||
* 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 +
|
||||
". Falling back to US-ASCII");
|
||||
charset = "US-ASCII";
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert and return as new String
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue