Limit translatable text size

This commit is contained in:
M66B
2021-06-27 22:23:46 +02:00
parent daaf192944
commit 9db1cce1e7

View File

@@ -305,6 +305,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private static final int MAX_RECIPIENTS_COMPACT = 3;
private static final int MAX_RECIPIENTS_NORMAL = 7;
private static final int MAX_QUOTE_LEVEL = 3;
private static final int MAX_TRANSLATABLE_TEXT_SIZE = 50 * 1024;
// https://www.iana.org/assignments/imap-jmap-keywords/imap-jmap-keywords.xhtml
private static final List<String> IMAP_KEYWORDS_BLACKLIST = Collections.unmodifiableList(Arrays.asList(
@@ -6679,6 +6680,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
String html = Helper.readText(file);
Document d = HtmlHelper.sanitizeCompose(context, html, false);
d.select("blockquote").remove();
HtmlHelper.truncate(d, MAX_TRANSLATABLE_TEXT_SIZE);
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, d, null, null);
return ssb.toString()
.replace("\uFFFC", "") // Object replacement character