Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 238cf80e authored by cketti's avatar cketti
Browse files

Fix SMTP dot stuffing at start of stream

parent 69ba305f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+9 −4
Original line number Diff line number Diff line
@@ -30,11 +30,16 @@ public class SmtpDataStuffingTest {

    @Test
    public void dotAtStartOfStream() throws IOException {
        smtpDataStuffing.write(bytesFor("...Hello .. dots."));
        smtpDataStuffing.write(bytesFor(".Hello dots"));

        //FIXME: The first line is a line, too. So This should be dot stuffed.
        // See https://tools.ietf.org/html/rfc5321#section-4.5.2
        assertEquals("...Hello .. dots.", buffer.readUtf8());
        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