Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit cd5c4bf9 authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #2903 from k9mail/decrypted-preamble

Don't ignore preamble and epilogue in decrypted messages
parents bfc2dcba d2443276
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
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() + "'");
            }
        }
    }
}