Fix SMTP dot stuffing at start of stream
This commit is contained in:
parent
69ba305f2a
commit
238cf80ec9
2 changed files with 10 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue