From 58a98dd0839caef7577b841e97c971c8a500fc03 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 28 Mar 2020 19:51:12 +0100 Subject: [PATCH] Fixed displaying Usenet signature with format flowed --- .../main/java/eu/faircode/email/MessageHelper.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index ba6616e3ad..bf174b7c03 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1459,8 +1459,15 @@ public class MessageHelper { if (part.isMimeType("text/plain")) { // https://tools.ietf.org/html/rfc3676 - if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) - result = result.replaceAll(" \\r?\\n", " "); + if ("flowed".equalsIgnoreCase(ct.getParameter("format"))) { + StringBuilder flowed = new StringBuilder(); + for (String line : result.split("\\r?\\n")) { + flowed.append(line); + if (!line.endsWith(" ") || "-- ".equals(line)) + flowed.append("\r\n"); + } + result = flowed.toString(); + } result = "
" + HtmlHelper.formatPre(result) + "
"; } else if (part.isMimeType("text/html")) { if (TextUtils.isEmpty(charset)) {