Loading k9mail-library/src/main/java/com/fsck/k9/mail/internet/FlowedMessageUtils.java 0 → 100644 +20 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; import static com.fsck.k9.mail.internet.MimeUtility.getHeaderParameter; import static com.fsck.k9.mail.internet.MimeUtility.isFormatFlowed; public class FlowedMessageUtils { private static final String HEADER_PARAM_DELSP = "delsp"; private static final String HEADER_DELSP_YES = "yes"; static boolean isDelSp(String contentType) { if (isFormatFlowed(contentType)) { String delSpParameter = getHeaderParameter(contentType, HEADER_PARAM_DELSP); return HEADER_DELSP_YES.equalsIgnoreCase(delSpParameter); } return false; } } k9mail-library/src/main/java/com/fsck/k9/mail/internet/Viewable.java +6 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,14 @@ public interface Viewable { } class Flowed extends Textual { private boolean delSp; public Flowed(Part part) { super(part); this.delSp = FlowedMessageUtils.isDelSp(part.getContentType()); } public boolean isDelSp() { return delSp; } } Loading k9mail-library/src/test/java/com/fsck/k9/mail/internet/FlowedMessageUtilsTest.java 0 → 100644 +32 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; import org.junit.Test; import static com.fsck.k9.mail.internet.FlowedMessageUtils.isDelSp; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class FlowedMessageUtilsTest { @Test public void isDelSp_withFormatFlowed_shouldReturnTrue() throws Exception { assertTrue(isDelSp("text/plain; format=flowed; delsp=yes")); } @Test public void isDelSp_withTextPlainFormatFlowed_shoulReturnFalse() throws Exception { assertFalse(isDelSp("text/plain; format=flowed")); } @Test public void isDelSp_withoutFormatFlowed_shouldReturnFalse() throws Exception { assertFalse(isDelSp("text/plain; delsp=yes")); } @Test public void idDelSp_withTextHtmlFormatFlowed_shouldReturnFalse() throws Exception { assertFalse(isDelSp("text/html; format=flowed; delsp=yes")); } } k9mail-library/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,6 @@ public class MimeUtilityTest { public void isFormatFlowed_withTextHtmlFormatFlowed__shouldReturnFalse() throws Exception { assertFalse(MimeUtility.isFormatFlowed("text/html; format=flowed")); } } k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java +5 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import timber.log.Timber; import com.fsck.k9.Globals; import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.message.html.HtmlConverter; import com.fsck.k9.message.html.HtmlSanitizer; import com.fsck.k9.mail.Address; Loading Loading @@ -233,7 +234,8 @@ public class MessageViewInfoExtractor { if (t == null) { t = ""; } else if (viewable instanceof Flowed) { t = FlowedMessageUtils.deflow(t, false); boolean delSp = ((Flowed) viewable).isDelSp(); t = FlowedMessageUtils.deflow(t, delSp); t = HtmlConverter.textToHtml(t); } else if (viewable instanceof Text) { t = HtmlConverter.textToHtml(t); Loading Loading @@ -271,7 +273,8 @@ public class MessageViewInfoExtractor { } else if (viewable instanceof Html) { t = HtmlConverter.htmlToText(t); } else if (viewable instanceof Flowed) { t = FlowedMessageUtils.deflow(t, false); boolean delSp = ((Flowed) viewable).isDelSp(); t = FlowedMessageUtils.deflow(t, delSp); } else if (!(viewable instanceof Text)) { throw new IllegalStateException("unhandled case!"); } Loading Loading
k9mail-library/src/main/java/com/fsck/k9/mail/internet/FlowedMessageUtils.java 0 → 100644 +20 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; import static com.fsck.k9.mail.internet.MimeUtility.getHeaderParameter; import static com.fsck.k9.mail.internet.MimeUtility.isFormatFlowed; public class FlowedMessageUtils { private static final String HEADER_PARAM_DELSP = "delsp"; private static final String HEADER_DELSP_YES = "yes"; static boolean isDelSp(String contentType) { if (isFormatFlowed(contentType)) { String delSpParameter = getHeaderParameter(contentType, HEADER_PARAM_DELSP); return HEADER_DELSP_YES.equalsIgnoreCase(delSpParameter); } return false; } }
k9mail-library/src/main/java/com/fsck/k9/mail/internet/Viewable.java +6 −0 Original line number Diff line number Diff line Loading @@ -42,8 +42,14 @@ public interface Viewable { } class Flowed extends Textual { private boolean delSp; public Flowed(Part part) { super(part); this.delSp = FlowedMessageUtils.isDelSp(part.getContentType()); } public boolean isDelSp() { return delSp; } } Loading
k9mail-library/src/test/java/com/fsck/k9/mail/internet/FlowedMessageUtilsTest.java 0 → 100644 +32 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.internet; import org.junit.Test; import static com.fsck.k9.mail.internet.FlowedMessageUtils.isDelSp; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class FlowedMessageUtilsTest { @Test public void isDelSp_withFormatFlowed_shouldReturnTrue() throws Exception { assertTrue(isDelSp("text/plain; format=flowed; delsp=yes")); } @Test public void isDelSp_withTextPlainFormatFlowed_shoulReturnFalse() throws Exception { assertFalse(isDelSp("text/plain; format=flowed")); } @Test public void isDelSp_withoutFormatFlowed_shouldReturnFalse() throws Exception { assertFalse(isDelSp("text/plain; delsp=yes")); } @Test public void idDelSp_withTextHtmlFormatFlowed_shouldReturnFalse() throws Exception { assertFalse(isDelSp("text/html; format=flowed; delsp=yes")); } }
k9mail-library/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -148,4 +148,6 @@ public class MimeUtilityTest { public void isFormatFlowed_withTextHtmlFormatFlowed__shouldReturnFalse() throws Exception { assertFalse(MimeUtility.isFormatFlowed("text/html; format=flowed")); } }
k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java +5 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import timber.log.Timber; import com.fsck.k9.Globals; import com.fsck.k9.K9; import com.fsck.k9.R; import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.message.html.HtmlConverter; import com.fsck.k9.message.html.HtmlSanitizer; import com.fsck.k9.mail.Address; Loading Loading @@ -233,7 +234,8 @@ public class MessageViewInfoExtractor { if (t == null) { t = ""; } else if (viewable instanceof Flowed) { t = FlowedMessageUtils.deflow(t, false); boolean delSp = ((Flowed) viewable).isDelSp(); t = FlowedMessageUtils.deflow(t, delSp); t = HtmlConverter.textToHtml(t); } else if (viewable instanceof Text) { t = HtmlConverter.textToHtml(t); Loading Loading @@ -271,7 +273,8 @@ public class MessageViewInfoExtractor { } else if (viewable instanceof Html) { t = HtmlConverter.htmlToText(t); } else if (viewable instanceof Flowed) { t = FlowedMessageUtils.deflow(t, false); boolean delSp = ((Flowed) viewable).isDelSp(); t = FlowedMessageUtils.deflow(t, delSp); } else if (!(viewable instanceof Text)) { throw new IllegalStateException("unhandled case!"); } Loading