prevent crash

pull/201/head
M66B 3 years ago
parent f52a4e842e
commit 7eaed34d54

@ -164,10 +164,15 @@ public class HtmlEx {
} }
private /* static */ String getTextDirection(Spanned text, int start, int end) { private /* static */ String getTextDirection(Spanned text, int start, int end) {
if (TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(text, start, end - start)) { try {
return " dir=\"rtl\""; if (TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(text, start, end - start)) {
} else { return " dir=\"rtl\"";
return " dir=\"ltr\""; } else {
return " dir=\"ltr\"";
}
} catch (Throwable ex) {
eu.faircode.email.Log.e(ex);
return "";
} }
} }

@ -19,6 +19,9 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B) Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/ */
import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_INDIVIDUAL;
import static org.w3c.css.sac.Condition.SAC_CLASS_CONDITION;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -118,9 +121,6 @@ import javax.mail.internet.InternetHeaders;
import javax.mail.internet.MailDateFormat; import javax.mail.internet.MailDateFormat;
import javax.mail.internet.MimeUtility; import javax.mail.internet.MimeUtility;
import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_INDIVIDUAL;
import static org.w3c.css.sac.Condition.SAC_CLASS_CONDITION;
public class HtmlHelper { public class HtmlHelper {
static final int PREVIEW_SIZE = 500; // characters static final int PREVIEW_SIZE = 500; // characters
@ -2625,7 +2625,14 @@ public class HtmlHelper {
case "text-align": case "text-align":
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-align // https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
Layout.Alignment alignment = null; Layout.Alignment alignment = null;
boolean rtl = TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(ssb, start, ssb.length() - start); boolean rtl;
try {
rtl = TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(ssb, start, ssb.length() - start);
} catch (Throwable ex) {
// IllegalArgumentException
Log.e(ex);
rtl = false;
}
switch (value) { switch (value) {
case "left": case "left":
case "start": case "start":

Loading…
Cancel
Save