mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Implemented data stuffing.
This commit is contained in:
parent
45036ae5c8
commit
0422cae33e
43
src/com/fsck/k9/mail/transport/SmtpDataStuffing.java
Normal file
43
src/com/fsck/k9/mail/transport/SmtpDataStuffing.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.fsck.k9.mail.transport;
|
||||
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class SmtpDataStuffing extends FilterOutputStream
|
||||
{
|
||||
private static final int STATE_NORMAL = 0;
|
||||
private static final int STATE_CR = 1;
|
||||
private static final int STATE_CRLF = 2;
|
||||
|
||||
private int state = STATE_NORMAL;
|
||||
|
||||
public SmtpDataStuffing(OutputStream out)
|
||||
{
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int oneByte) throws IOException
|
||||
{
|
||||
if (oneByte == '\r')
|
||||
{
|
||||
state = STATE_CR;
|
||||
}
|
||||
else if ((state == STATE_CR) && (oneByte == '\n'))
|
||||
{
|
||||
state = STATE_CRLF;
|
||||
}
|
||||
else if ((state == STATE_CRLF) && (oneByte == '.'))
|
||||
{
|
||||
// Read <CR><LF><DOT> so this line needs an additional period.
|
||||
super.write('.');
|
||||
state = STATE_NORMAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = STATE_NORMAL;
|
||||
}
|
||||
super.write(oneByte);
|
||||
}
|
||||
}
|
@ -317,9 +317,9 @@ public class SmtpTransport extends Transport
|
||||
message.setRecipients(RecipientType.BCC, null);
|
||||
executeSimpleCommand("DATA");
|
||||
|
||||
//TODO: Data stuffing (RFC 821 4.5.2.)
|
||||
EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream(
|
||||
new BufferedOutputStream(mOut, 1024));
|
||||
new SmtpDataStuffing(
|
||||
new BufferedOutputStream(mOut, 1024)));
|
||||
|
||||
message.writeTo(msgOut);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user