Don't save reference to multipart/encrypted "root" in decrypted parts

This commit is contained in:
cketti 2015-01-29 15:16:59 +01:00
parent 1046308a38
commit 7b67d054a4
2 changed files with 9 additions and 23 deletions

View file

@ -27,8 +27,8 @@ import org.apache.james.mime4j.stream.MimeConfig;
public class DecryptStreamParser {
public static DecryptedBodyPart parse(Part multipartEncrypted, InputStream inputStream) throws MessagingException, IOException {
DecryptedBodyPart decryptedRootPart = new DecryptedBodyPart(multipartEncrypted);
public static DecryptedBodyPart parse(InputStream inputStream) throws MessagingException, IOException {
DecryptedBodyPart decryptedRootPart = new DecryptedBodyPart();
MimeConfig parserConfig = new MimeConfig();
parserConfig.setMaxHeaderLen(-1);
@ -36,7 +36,7 @@ public class DecryptStreamParser {
parserConfig.setMaxHeaderCount(-1);
MimeStreamParser parser = new MimeStreamParser(parserConfig);
parser.setContentHandler(new PartBuilder(multipartEncrypted, decryptedRootPart));
parser.setContentHandler(new PartBuilder(decryptedRootPart));
parser.setRecurse();
try {
@ -64,12 +64,10 @@ public class DecryptStreamParser {
private static class PartBuilder implements ContentHandler {
private final Part multipartEncrypted;
private final DecryptedBodyPart decryptedRootPart;
private final Stack<Object> stack = new Stack<Object>();
public PartBuilder(Part multipartEncrypted, DecryptedBodyPart decryptedRootPart) throws MessagingException {
this.multipartEncrypted = multipartEncrypted;
public PartBuilder(DecryptedBodyPart decryptedRootPart) throws MessagingException {
this.decryptedRootPart = decryptedRootPart;
}
@ -80,7 +78,7 @@ public class DecryptStreamParser {
} else {
Part part = (Part) stack.peek();
Message innerMessage = new DecryptedMimeMessage(multipartEncrypted);
Message innerMessage = new MimeMessage();
part.setBody(innerMessage);
stack.push(innerMessage);
@ -97,7 +95,7 @@ public class DecryptStreamParser {
try {
Multipart multipart = (Multipart) stack.peek();
BodyPart bodyPart = new DecryptedBodyPart(multipartEncrypted);
BodyPart bodyPart = new MimeBodyPart();
multipart.addBodyPart(bodyPart);
stack.push(bodyPart);
@ -183,18 +181,8 @@ public class DecryptStreamParser {
}
public static class DecryptedBodyPart extends MimeBodyPart {
private final Part multipartEncrypted;
public DecryptedBodyPart(Part multipartEncrypted) throws MessagingException {
this.multipartEncrypted = multipartEncrypted;
}
}
public static class DecryptedMimeMessage extends MimeMessage {
private final Part multipartEncrypted;
public DecryptedMimeMessage(Part multipartEncrypted) {
this.multipartEncrypted = multipartEncrypted;
public DecryptedBodyPart() throws MessagingException {
// Do nothing
}
}
}

View file

@ -71,8 +71,6 @@ import com.fsck.k9.ui.message.DecodeMessageLoader;
import com.fsck.k9.ui.message.LocalMessageLoader;
import com.fsck.k9.view.MessageHeader;
import org.openintents.openpgp.IOpenPgpService;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
import org.openintents.openpgp.util.OpenPgpServiceConnection;
@ -381,7 +379,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
protected DecryptedBodyPart doInBackground(Void... params) {
DecryptedBodyPart decryptedPart = null;
try {
decryptedPart = DecryptStreamParser.parse(currentlyDecryptingPart, decryptedInputStream);
decryptedPart = DecryptStreamParser.parse(decryptedInputStream);
latch.await();
} catch (InterruptedException e) {