Loading k9mail-library/src/main/java/com/fsck/k9/mail/filter/SmtpDataStuffing.java +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ public class SmtpDataStuffing extends FilterOutputStream { private static final int STATE_CR = 1; private static final int STATE_CRLF = 2; private int state = STATE_NORMAL; private int state = STATE_CRLF; public SmtpDataStuffing(OutputStream out) { super(out); Loading k9mail-library/src/test/java/com/fsck/k9/mail/filter/SmtpDataStuffingTest.java 0 → 100644 +55 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.filter; import java.io.IOException; import okio.Buffer; import okio.ByteString; import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.assertEquals; public class SmtpDataStuffingTest { private Buffer buffer; private SmtpDataStuffing smtpDataStuffing; @Before public void setUp() throws Exception { buffer = new Buffer(); smtpDataStuffing = new SmtpDataStuffing(buffer.outputStream()); } @Test public void dotAtStartOfLine() throws IOException { smtpDataStuffing.write(bytesFor("Hello dot\r\n.")); assertEquals("Hello dot\r\n..", buffer.readUtf8()); } @Test public void dotAtStartOfStream() throws IOException { smtpDataStuffing.write(bytesFor(".Hello dots")); assertEquals("..Hello dots", buffer.readUtf8()); } @Test public void linesNotStartingWithDot() throws IOException { smtpDataStuffing.write(bytesFor("Hello\r\nworld\r\n")); assertEquals("Hello\r\nworld\r\n", buffer.readUtf8()); } @Test public void dotsThatNeedStuffingMixedWithOnesThatDoNot() throws IOException { smtpDataStuffing.write(bytesFor("\r\n.Hello . dots.\r\n..\r\n.\r\n...")); assertEquals("\r\n..Hello . dots.\r\n...\r\n..\r\n....", buffer.readUtf8()); } private byte[] bytesFor(String input) { return ByteString.encodeUtf8(input).toByteArray(); } } Loading
k9mail-library/src/main/java/com/fsck/k9/mail/filter/SmtpDataStuffing.java +1 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ public class SmtpDataStuffing extends FilterOutputStream { private static final int STATE_CR = 1; private static final int STATE_CRLF = 2; private int state = STATE_NORMAL; private int state = STATE_CRLF; public SmtpDataStuffing(OutputStream out) { super(out); Loading
k9mail-library/src/test/java/com/fsck/k9/mail/filter/SmtpDataStuffingTest.java 0 → 100644 +55 −0 Original line number Diff line number Diff line package com.fsck.k9.mail.filter; import java.io.IOException; import okio.Buffer; import okio.ByteString; import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.assertEquals; public class SmtpDataStuffingTest { private Buffer buffer; private SmtpDataStuffing smtpDataStuffing; @Before public void setUp() throws Exception { buffer = new Buffer(); smtpDataStuffing = new SmtpDataStuffing(buffer.outputStream()); } @Test public void dotAtStartOfLine() throws IOException { smtpDataStuffing.write(bytesFor("Hello dot\r\n.")); assertEquals("Hello dot\r\n..", buffer.readUtf8()); } @Test public void dotAtStartOfStream() throws IOException { smtpDataStuffing.write(bytesFor(".Hello dots")); assertEquals("..Hello dots", buffer.readUtf8()); } @Test public void linesNotStartingWithDot() throws IOException { smtpDataStuffing.write(bytesFor("Hello\r\nworld\r\n")); assertEquals("Hello\r\nworld\r\n", buffer.readUtf8()); } @Test public void dotsThatNeedStuffingMixedWithOnesThatDoNot() throws IOException { smtpDataStuffing.write(bytesFor("\r\n.Hello . dots.\r\n..\r\n.\r\n...")); assertEquals("\r\n..Hello . dots.\r\n...\r\n..\r\n....", buffer.readUtf8()); } private byte[] bytesFor(String input) { return ByteString.encodeUtf8(input).toByteArray(); } }