diff --git a/app/src/main/java/eu/faircode/email/AI.java b/app/src/main/java/eu/faircode/email/AI.java index 376e1d1e01..ceade611d3 100644 --- a/app/src/main/java/eu/faircode/email/AI.java +++ b/app/src/main/java/eu/faircode/email/AI.java @@ -184,7 +184,7 @@ public class AI { if (remove_signatures) HtmlHelper.removeSignatures(d); - HtmlHelper.removeQuotes(d); + HtmlHelper.removeQuotes(d, true); d = HtmlHelper.sanitizeView(context, d, false); diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index eef38fd7db..890a10f449 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -437,7 +437,7 @@ public class EntityRule { Document d = JsoupEx.parse(html); if (skip_quotes) - HtmlHelper.removeQuotes(d); + HtmlHelper.removeQuotes(d, true); if (jsoup) { String selector = value.substring(JSOUP_PREFIX.length()); if (d.select(selector).isEmpty() != not) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogTranslate.java b/app/src/main/java/eu/faircode/email/FragmentDialogTranslate.java index 2504a4d4f0..5ac81d01e0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogTranslate.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogTranslate.java @@ -359,7 +359,7 @@ public class FragmentDialogTranslate extends FragmentDialogBase { if (remove_signatures) HtmlHelper.removeSignatures(d); - HtmlHelper.removeQuotes(d); + HtmlHelper.removeQuotes(d, true); d = HtmlHelper.sanitizeView(context, d, false); diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 39321c553d..c3aad4a9e2 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -2670,9 +2670,11 @@ public class HtmlHelper { } if (!preview_quotes) { - Element top = d.select("blockquote").first(); - if (top != null && top.previousElementSibling() == null) - top.remove(); + if (!removeQuotes(d, false)) { + Element top = d.select("blockquote").first(); + if (top != null && top.previousElementSibling() == null) + top.remove(); + } } for (Element bq : d.select("blockquote")) @@ -2875,51 +2877,54 @@ public class HtmlHelper { }); } - static void removeQuotes(Document d) { + static boolean removeQuotes(Document d, boolean all) { Elements quotes = d.body().select(".fairemail_quote"); - if (quotes.size() > 0) { + if (!quotes.isEmpty()) { quotes.remove(); - return; + return true; } // Gmail quotes = d.body().select(".gmail_quote"); - if (quotes.size() > 0) { + if (!quotes.isEmpty()) { quotes.remove(); - return; + return true; } // Outlook:
quotes = d.body().select("div#appendonsend"); - if (quotes.size() > 0) { + if (!quotes.isEmpty()) { quotes.nextAll().remove(); quotes.remove(); - return; + return true; } // ms-outlook-mobile quotes = d.body().select("div#divRplyFwdMsg"); - if (quotes.size() > 0) { + if (!quotes.isEmpty()) { quotes.nextAll().remove(); quotes.remove(); - return; + return true; } // Microsoft Word 15 quotes = d.body().select("div#mail-editor-reference-message-container"); - if (quotes.size() > 0) { + if (!quotes.isEmpty()) { quotes.remove(); - return; + return true; } // Web.de:
0) { + if (!quotes.isEmpty()) { quotes.remove(); - return; + return true; } - d.select("blockquote").remove(); + if (!all) + return false; + + return !d.select("blockquote").remove().isEmpty(); } static String truncate(String text, int at) {