Merge pull request #2903 from k9mail/decrypted-preamble
Don't ignore preamble and epilogue in decrypted messages
This commit is contained in:
commit
cd5c4bf9a6
1 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.fsck.k9.mailstore;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -134,12 +135,18 @@ public class MimePartStreamParser {
|
|||
|
||||
@Override
|
||||
public void preamble(InputStream is) throws MimeException, IOException {
|
||||
// Do nothing
|
||||
expect(MimeMultipart.class);
|
||||
ByteArrayOutputStream preamble = new ByteArrayOutputStream();
|
||||
IOUtils.copy(is, preamble);
|
||||
((MimeMultipart)stack.peek()).setPreamble(preamble.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void epilogue(InputStream is) throws MimeException, IOException {
|
||||
// Do nothing
|
||||
expect(MimeMultipart.class);
|
||||
ByteArrayOutputStream epilogue = new ByteArrayOutputStream();
|
||||
IOUtils.copy(is, epilogue);
|
||||
((MimeMultipart) stack.peek()).setEpilogue(epilogue.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,5 +181,12 @@ public class MimePartStreamParser {
|
|||
public void raw(InputStream is) throws MimeException, IOException {
|
||||
throw new IllegalStateException("Not implemented");
|
||||
}
|
||||
|
||||
private void expect(Class<?> c) {
|
||||
if (!c.isInstance(stack.peek())) {
|
||||
throw new IllegalStateException("Internal stack error: " + "Expected '"
|
||||
+ c.getName() + "' found '" + stack.peek().getClass().getName() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue