double dot filter : avoid end of message in body (triggers DELE errors)

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@105 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2007-11-13 22:23:48 +00:00
parent 3f7f9aca5c
commit dd99fd0d02
1 changed files with 20 additions and 1 deletions

View File

@ -1019,7 +1019,26 @@ public class ExchangeSession {
protected void writeBody(OutputStream os, MimeHeader mimeHeader) throws IOException {
OutputStream quotedOs;
try {
quotedOs = (MimeUtility.encode(os, mimeHeader.contentTransferEncoding));
// double dot filter : avoid end of message in body
quotedOs = new FilterOutputStream(os) {
byte state = 0;
public void write(int achar) throws IOException {
if (achar == 13 && state != 3) {
state = 1;
} else if (achar == 10 && state == 1) {
state = 2;
} else if (achar == '.' && state == 2) {
state = 3;
} else if (achar == 13) {
state = 0;
super.write('.');
} else {
state = 0;
}
super.write(achar);
}
};
quotedOs = (MimeUtility.encode(quotedOs, mimeHeader.contentTransferEncoding));
} catch (MessagingException e) {
throw new IOException(e + " " + e.getMessage());
}