Catch ParseException on get HTML

pull/156/head
M66B 5 years ago
parent 77beca5a34
commit 736e8d4dba

@ -800,23 +800,28 @@ public class MessageHelper {
throw new FolderClosedException(ex.getFolder(), "getHtml", ex); throw new FolderClosedException(ex.getFolder(), "getHtml", ex);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
text = true; warnings.add(ex.getMessage());
result = ex + "\n" + android.util.Log.getStackTraceString(ex); return null;
} }
ContentType ct = new ContentType(part.getContentType()); try {
String charset = ct.getParameter("charset"); ContentType ct = new ContentType(part.getContentType());
if (TextUtils.isEmpty(charset)) { String charset = ct.getParameter("charset");
if (BuildConfig.DEBUG) if (TextUtils.isEmpty(charset)) {
warnings.add(context.getString(R.string.title_no_charset, ct.toString())); if (BuildConfig.DEBUG)
if (part.isMimeType("text/plain")) { warnings.add(context.getString(R.string.title_no_charset, ct.toString()));
// The first 127 characters are the same as in US-ASCII if (part.isMimeType("text/plain")) {
result = new String(result.getBytes(StandardCharsets.ISO_8859_1)); // The first 127 characters are the same as in US-ASCII
result = new String(result.getBytes(StandardCharsets.ISO_8859_1));
}
} else {
if ("US-ASCII".equals(Charset.forName(charset).name()) &&
!"US-ASCII".equals(charset.toUpperCase()))
warnings.add(context.getString(R.string.title_no_charset, charset));
} }
} else { } catch (ParseException ex) {
if ("US-ASCII".equals(Charset.forName(charset).name()) && Log.w(ex);
!"US-ASCII".equals(charset.toUpperCase())) warnings.add(ex.getMessage());
warnings.add(context.getString(R.string.title_no_charset, charset));
} }
if (part.isMimeType("text/plain") || text) { if (part.isMimeType("text/plain") || text) {

Loading…
Cancel
Save