From ac628a265daa6583bbe0c425163db5697a9b527e Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 19 Sep 2017 00:21:45 +0200 Subject: [PATCH] use available methods for structure detection --- .../com/fsck/k9/crypto/MessageCryptoStructureDetector.java | 2 +- .../com/fsck/k9/mailstore/MessageViewInfoExtractor.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/crypto/MessageCryptoStructureDetector.java b/k9mail/src/main/java/com/fsck/k9/crypto/MessageCryptoStructureDetector.java index 974811957..cd8bd7034 100644 --- a/k9mail/src/main/java/com/fsck/k9/crypto/MessageCryptoStructureDetector.java +++ b/k9mail/src/main/java/com/fsck/k9/crypto/MessageCryptoStructureDetector.java @@ -233,7 +233,7 @@ public class MessageCryptoStructureDetector { return dataUnavailable || protocolMatches; } - private static boolean isPartMultipartEncrypted(Part part) { + public static boolean isPartMultipartEncrypted(Part part) { if (!isSameMimeType(part.getMimeType(), MULTIPART_ENCRYPTED)) { return false; } diff --git a/k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java b/k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java index a51ddff2d..feeb06946 100644 --- a/k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java +++ b/k9mail/src/main/java/com/fsck/k9/mailstore/MessageViewInfoExtractor.java @@ -83,10 +83,9 @@ public class MessageViewInfoExtractor { return extractSimpleMessageForView(message, message); } - boolean isOpenPgpEncrypted = - MimeUtility.isSameMimeType(cryptoContentPart.getMimeType(), "multipart/encrypted") && - MimeUtility.isSameMimeType(getHeaderParameter(cryptoContentPart.getContentType(), "protocol"), - "application/pgp-encrypted"); + boolean isOpenPgpEncrypted = (MessageCryptoStructureDetector.isPartMultipartEncrypted(cryptoContentPart) && + MessageCryptoStructureDetector.isMultipartEncryptedOpenPgpProtocol(cryptoContentPart)) || + MessageCryptoStructureDetector.isPartPgpInlineEncrypted(cryptoContentPart); if (!K9.isOpenPgpProviderConfigured() && isOpenPgpEncrypted) { CryptoResultAnnotation noProviderAnnotation = CryptoResultAnnotation.createErrorAnnotation( CryptoError.OPENPGP_ENCRYPTED_NO_PROVIDER, null);