skip mime parsing if we already know the content type isn't suitable

This commit is contained in:
Vincent Breitmoser
2015-09-19 15:25:40 +02:00
parent e7185bd1b8
commit 5330a91fef

View File

@@ -86,6 +86,11 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
DecryptVerifyResult decryptResult = null; DecryptVerifyResult decryptResult = null;
PgpDecryptVerifyInputParcel decryptInput = input.getDecryptInput(); 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) { if (decryptInput != null) {
log.add(LogType.MSG_DATA_OPENPGP, 1); log.add(LogType.MSG_DATA_OPENPGP, 1);
@@ -113,12 +118,20 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
currentInputUri = input.getInputUri(); currentInputUri = input.getInputUri();
} }
// If we aren't supposed to attempt mime decode, we are done here // don't even attempt if we know the data isn't suitable for mime content
if (!input.getMimeDecode()) { boolean skipMimeParsing = false;
if (decryptResult != null && decryptResult.getDecryptionMetadata() != null) {
if (decryptInput == null) { String contentType = decryptResult.getDecryptionMetadata().getMimeType();
throw new AssertionError("no decryption or mime decoding, this is probably a bug"); 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); log.add(LogType.MSG_DATA_SKIP_MIME, 1);