Don't save reference to multipart/encrypted "root" in decrypted parts
This commit is contained in:
parent
1046308a38
commit
7b67d054a4
2 changed files with 9 additions and 23 deletions
|
@ -27,8 +27,8 @@ import org.apache.james.mime4j.stream.MimeConfig;
|
||||||
|
|
||||||
|
|
||||||
public class DecryptStreamParser {
|
public class DecryptStreamParser {
|
||||||
public static DecryptedBodyPart parse(Part multipartEncrypted, InputStream inputStream) throws MessagingException, IOException {
|
public static DecryptedBodyPart parse(InputStream inputStream) throws MessagingException, IOException {
|
||||||
DecryptedBodyPart decryptedRootPart = new DecryptedBodyPart(multipartEncrypted);
|
DecryptedBodyPart decryptedRootPart = new DecryptedBodyPart();
|
||||||
|
|
||||||
MimeConfig parserConfig = new MimeConfig();
|
MimeConfig parserConfig = new MimeConfig();
|
||||||
parserConfig.setMaxHeaderLen(-1);
|
parserConfig.setMaxHeaderLen(-1);
|
||||||
|
@ -36,7 +36,7 @@ public class DecryptStreamParser {
|
||||||
parserConfig.setMaxHeaderCount(-1);
|
parserConfig.setMaxHeaderCount(-1);
|
||||||
|
|
||||||
MimeStreamParser parser = new MimeStreamParser(parserConfig);
|
MimeStreamParser parser = new MimeStreamParser(parserConfig);
|
||||||
parser.setContentHandler(new PartBuilder(multipartEncrypted, decryptedRootPart));
|
parser.setContentHandler(new PartBuilder(decryptedRootPart));
|
||||||
parser.setRecurse();
|
parser.setRecurse();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -64,12 +64,10 @@ public class DecryptStreamParser {
|
||||||
|
|
||||||
|
|
||||||
private static class PartBuilder implements ContentHandler {
|
private static class PartBuilder implements ContentHandler {
|
||||||
private final Part multipartEncrypted;
|
|
||||||
private final DecryptedBodyPart decryptedRootPart;
|
private final DecryptedBodyPart decryptedRootPart;
|
||||||
private final Stack<Object> stack = new Stack<Object>();
|
private final Stack<Object> stack = new Stack<Object>();
|
||||||
|
|
||||||
public PartBuilder(Part multipartEncrypted, DecryptedBodyPart decryptedRootPart) throws MessagingException {
|
public PartBuilder(DecryptedBodyPart decryptedRootPart) throws MessagingException {
|
||||||
this.multipartEncrypted = multipartEncrypted;
|
|
||||||
this.decryptedRootPart = decryptedRootPart;
|
this.decryptedRootPart = decryptedRootPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +78,7 @@ public class DecryptStreamParser {
|
||||||
} else {
|
} else {
|
||||||
Part part = (Part) stack.peek();
|
Part part = (Part) stack.peek();
|
||||||
|
|
||||||
Message innerMessage = new DecryptedMimeMessage(multipartEncrypted);
|
Message innerMessage = new MimeMessage();
|
||||||
part.setBody(innerMessage);
|
part.setBody(innerMessage);
|
||||||
|
|
||||||
stack.push(innerMessage);
|
stack.push(innerMessage);
|
||||||
|
@ -97,7 +95,7 @@ public class DecryptStreamParser {
|
||||||
try {
|
try {
|
||||||
Multipart multipart = (Multipart) stack.peek();
|
Multipart multipart = (Multipart) stack.peek();
|
||||||
|
|
||||||
BodyPart bodyPart = new DecryptedBodyPart(multipartEncrypted);
|
BodyPart bodyPart = new MimeBodyPart();
|
||||||
multipart.addBodyPart(bodyPart);
|
multipart.addBodyPart(bodyPart);
|
||||||
|
|
||||||
stack.push(bodyPart);
|
stack.push(bodyPart);
|
||||||
|
@ -183,18 +181,8 @@ public class DecryptStreamParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DecryptedBodyPart extends MimeBodyPart {
|
public static class DecryptedBodyPart extends MimeBodyPart {
|
||||||
private final Part multipartEncrypted;
|
public DecryptedBodyPart() throws MessagingException {
|
||||||
|
// Do nothing
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,6 @@ import com.fsck.k9.ui.message.DecodeMessageLoader;
|
||||||
import com.fsck.k9.ui.message.LocalMessageLoader;
|
import com.fsck.k9.ui.message.LocalMessageLoader;
|
||||||
import com.fsck.k9.view.MessageHeader;
|
import com.fsck.k9.view.MessageHeader;
|
||||||
import org.openintents.openpgp.IOpenPgpService;
|
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;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
|
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
|
||||||
import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
||||||
|
@ -381,7 +379,7 @@ public class MessageViewFragment extends Fragment implements ConfirmationDialogF
|
||||||
protected DecryptedBodyPart doInBackground(Void... params) {
|
protected DecryptedBodyPart doInBackground(Void... params) {
|
||||||
DecryptedBodyPart decryptedPart = null;
|
DecryptedBodyPart decryptedPart = null;
|
||||||
try {
|
try {
|
||||||
decryptedPart = DecryptStreamParser.parse(currentlyDecryptingPart, decryptedInputStream);
|
decryptedPart = DecryptStreamParser.parse(decryptedInputStream);
|
||||||
|
|
||||||
latch.await();
|
latch.await();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
Loading…
Reference in a new issue