From d424cd752aec2e13a06b359c37da0855b0e04f7a Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 14 Mar 2022 10:17:40 +0100 Subject: [PATCH] Break flow on start/end quote --- app/src/main/java/eu/faircode/email/HtmlHelper.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index e0648aba22..b21cace650 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -2016,6 +2016,7 @@ public class HtmlHelper { // https://tools.ietf.org/html/rfc3676 static String flow(String text, boolean delsp) { boolean continuation = false; + boolean inquote = false; StringBuilder flowed = new StringBuilder(); String[] lines = text.split("\\r?\\n"); for (int l = 0; l < lines.length; l++) { @@ -2025,6 +2026,15 @@ public class HtmlHelper { if (delsp && line.endsWith(" ")) line = line.substring(0, line.length() - 1); + boolean q = line.startsWith(">"); + if (q != inquote) { + int len = flowed.length(); + if (len > 0 && flowed.charAt(len - 1) != '\n') + flowed.append("\n"); + continuation = false; + } + inquote = q; + if (continuation) while (line.startsWith(">")) { line = line.substring(1);