Simplified CR/LF mbox handling

This commit is contained in:
M66B 2021-04-17 21:09:32 +02:00
parent d8a8536e4c
commit 07b005d586
1 changed files with 4 additions and 12 deletions

View File

@ -909,25 +909,18 @@ public class FragmentFolders extends FragmentBase {
Message imessage = MessageHelper.from(context, message, null, isession, false);
imessage.writeTo(new FilterOutputStream(out) {
private boolean cr = false;
private boolean lf = false;
private ByteArrayOutputStream buffer = new ByteArrayOutputStream(998);
@Override
public void write(int b) throws IOException {
if (b == 13 /* CR */) {
if (cr || lf)
if (cr) // another
line();
cr = true;
} else if (b == 10 /* LF */) {
if (cr)
line();
else if (lf) {
line();
lf = true;
} else
lf = true;
line();
} else {
if (cr || lf)
if (cr) // dangling
line();
buffer.write(b);
}
@ -935,7 +928,7 @@ public class FragmentFolders extends FragmentBase {
@Override
public void flush() throws IOException {
if (buffer.size() > 0 || cr || lf)
if (buffer.size() > 0 || cr /* dangling */)
line();
out.write(10);
super.flush();
@ -964,7 +957,6 @@ public class FragmentFolders extends FragmentBase {
buffer.reset();
cr = false;
lf = false;
}
});
}