diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 2ac2de6006..77b846faa4 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -936,6 +936,27 @@ public class HtmlHelper { return false; } + // https://tools.ietf.org/html/rfc3676 + static String flow(String text) { + boolean continuation = false; + StringBuilder flowed = new StringBuilder(); + for (String line : text.split("\\r?\\n")) { + if (continuation) + while (line.startsWith(">")) { + line = line.substring(1); + if (line.startsWith(" ")) + line = line.substring(1); + } + + continuation = (line.endsWith(" ") && !"-- ".equals(line)); + + flowed.append(line); + if (!continuation) + flowed.append("\r\n"); + } + return flowed.toString(); + } + static String formatPre(String text) { int level = 0; StringBuilder sb = new StringBuilder(); diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 21e193d6e2..f3818531fe 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1481,26 +1481,8 @@ public class MessageHelper { warnings.add(context.getString(R.string.title_no_charset, charset)); if (part.isMimeType("text/plain")) { - // https://tools.ietf.org/html/rfc3676 - if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) { - boolean continuation = false; - StringBuilder flowed = new StringBuilder(); - for (String line : result.split("\\r?\\n")) { - if (continuation) - while (line.startsWith(">")) { - line = line.substring(1); - if (line.startsWith(" ")) - line = line.substring(1); - } - - continuation = (line.endsWith(" ") && !"-- ".equals(line)); - - flowed.append(line); - if (!continuation) - flowed.append("\r\n"); - } - result = flowed.toString(); - } + if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) + result = HtmlHelper.flow(result); result = "
" + HtmlHelper.formatPre(result) + "
"; } else if (part.isMimeType("text/html")) { if (TextUtils.isEmpty(charset)) {