aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-19 15:25:40 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-19 15:27:14 +0200
commit5330a91fef160b7d1bc4bae997997416ee01922c (patch)
tree73a372012de53866ead2078890eeaa20017ba842 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
parente7185bd1b80b2ccf87b8ec534d04a410fa5037a1 (diff)
downloadopen-keychain-5330a91fef160b7d1bc4bae997997416ee01922c.tar.gz
open-keychain-5330a91fef160b7d1bc4bae997997416ee01922c.tar.bz2
open-keychain-5330a91fef160b7d1bc4bae997997416ee01922c.zip
skip mime parsing if we already know the content type isn't suitable
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
index 0bc4c1ecc..9170dc139 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java
@@ -86,6 +86,11 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
DecryptVerifyResult decryptResult = null;
PgpDecryptVerifyInputParcel decryptInput = input.getDecryptInput();
+
+ if (!input.getMimeDecode() && decryptInput == null) {
+ throw new AssertionError("no decryption or mime decoding, this is probably a bug");
+ }
+
if (decryptInput != null) {
log.add(LogType.MSG_DATA_OPENPGP, 1);
@@ -113,12 +118,20 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
currentInputUri = input.getInputUri();
}
- // If we aren't supposed to attempt mime decode, we are done here
- if (!input.getMimeDecode()) {
-
- if (decryptInput == null) {
- throw new AssertionError("no decryption or mime decoding, this is probably a bug");
+ // don't even attempt if we know the data isn't suitable for mime content
+ boolean skipMimeParsing = false;
+ if (decryptResult != null && decryptResult.getDecryptionMetadata() != null) {
+ String contentType = decryptResult.getDecryptionMetadata().getMimeType();
+ if (contentType != null
+ && !contentType.startsWith("multipart/")
+ && !contentType.startsWith("text/")
+ && !contentType.startsWith("application/")) {
+ skipMimeParsing = true;
}
+ }
+
+ // If we aren't supposed to attempt mime decode after decryption, we are done here
+ if (skipMimeParsing || !input.getMimeDecode()) {
log.add(LogType.MSG_DATA_SKIP_MIME, 1);