From 6c4461cd132a397baab7e8ba7ef7c1864b877bc0 Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Thu, 9 May 2013 23:08:11 +0900 Subject: [PATCH] Fix to preserve spaces --- src/com/fsck/k9/helper/HtmlConverter.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/com/fsck/k9/helper/HtmlConverter.java b/src/com/fsck/k9/helper/HtmlConverter.java index c39337672..2002f2767 100644 --- a/src/com/fsck/k9/helper/HtmlConverter.java +++ b/src/com/fsck/k9/helper/HtmlConverter.java @@ -218,6 +218,22 @@ public class HtmlConverter { try { int c; while ((c = reader.read()) != -1) { + switch (c) { + case '\n': + case '&': + case '<': + case '\r': + if (isStartOfLine) { + while (spaces-- > 0) { + buff.append(' '); + } + } + else { + spaces = 0; + } + break; + } + switch (c) { case '\n': // pine treats
as two newlines, but
as one newline. Use
so our messages aren't @@ -225,14 +241,11 @@ public class HtmlConverter { buff.append(HTML_NEWLINE); isStartOfLine = true; quotesThisLine = 0; - spaces = 0; break; case '&': - spaces = 0; buff.append("&"); break; case '<': - spaces = 0; buff.append("<"); break; case '>': @@ -248,12 +261,9 @@ public class HtmlConverter { } break; case '\r': - spaces = 0; break; case ' ': if (isStartOfLine) { - // If we're still in the start of the line and we have spaces, don't output them, since they - // may be collapsed by our div-converting magic. spaces++; } else {