diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-19 15:25:18 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-19 15:27:04 +0200 |
commit | e7185bd1b80b2ccf87b8ec534d04a410fa5037a1 (patch) | |
tree | 190edf82a44d8ce37a5b2bf0839a9438efa8139e /OpenKeychain/src | |
parent | 03269815f1937064fcad310fdd76902207d298f4 (diff) | |
download | open-keychain-e7185bd1b80b2ccf87b8ec534d04a410fa5037a1.tar.gz open-keychain-e7185bd1b80b2ccf87b8ec534d04a410fa5037a1.tar.bz2 open-keychain-e7185bd1b80b2ccf87b8ec534d04a410fa5037a1.zip |
fix fallback for non-mime data
Diffstat (limited to 'OpenKeychain/src')
3 files changed, 24 insertions, 21 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 d9e48af8a..0bc4c1ecc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/InputDataOperation.java @@ -309,25 +309,32 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> { log.add(LogType.MSG_DATA_MIME, 1); - // open current uri for input - InputStream in = mContext.getContentResolver().openInputStream(currentInputUri); - parser.parse(in); + try { - if (mSignedDataUri != null) { + // open current uri for input + InputStream in = mContext.getContentResolver().openInputStream(currentInputUri); + parser.parse(in); - if (decryptResult != null) { - decryptResult.setSignatureResult(mSignedDataResult.getSignatureResult()); - } else { - decryptResult = mSignedDataResult; - } + if (mSignedDataUri != null) { - // the actual content is the signed data now (and will be passed verbatim, if parsing fails) - currentInputUri = mSignedDataUri; - in = mContext.getContentResolver().openInputStream(currentInputUri); - // reset signed data result, to indicate to the parser that it is in the inner part - mSignedDataResult = null; - parser.parse(in); + if (decryptResult != null) { + decryptResult.setSignatureResult(mSignedDataResult.getSignatureResult()); + } else { + decryptResult = mSignedDataResult; + } + // the actual content is the signed data now (and will be passed verbatim, if parsing fails) + currentInputUri = mSignedDataUri; + in = mContext.getContentResolver().openInputStream(currentInputUri); + // reset signed data result, to indicate to the parser that it is in the inner part + mSignedDataResult = null; + parser.parse(in); + + } + } catch (MimeException e) { + // a mime error likely means that this wasn't mime data, after all + e.printStackTrace(); + log.add(LogType.MSG_DATA_MIME_BAD, 2); } // if we found data, return success @@ -363,10 +370,6 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> { e.printStackTrace(); log.add(LogType.MSG_DATA_ERROR_IO, 2); return new InputDataResult(InputDataResult.RESULT_ERROR, log); - } catch (MimeException e) { - e.printStackTrace(); - log.add(LogType.MSG_DATA_MIME_ERROR, 2); - return new InputDataResult(InputDataResult.RESULT_ERROR, log); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index b1dcc9202..a03658808 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -837,7 +837,7 @@ public abstract class OperationResult implements Parcelable { MSG_DATA_DETACHED_NESTED(LogLevel.WARN, R.string.msg_data_detached_nested), MSG_DATA_DETACHED_TRAILING (LogLevel.WARN, R.string.msg_data_detached_trailing), MSG_DATA_DETACHED_UNSUPPORTED (LogLevel.WARN, R.string.msg_data_detached_unsupported), - MSG_DATA_MIME_ERROR (LogLevel.ERROR, R.string.msg_data_mime_error), + MSG_DATA_MIME_BAD(LogLevel.INFO, R.string.msg_data_mime_bad), MSG_DATA_MIME_FILENAME (LogLevel.DEBUG, R.string.msg_data_mime_filename), MSG_DATA_MIME_LENGTH (LogLevel.DEBUG, R.string.msg_data_mime_length), MSG_DATA_MIME (LogLevel.DEBUG, R.string.msg_data_mime), diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index f12be176e..62083cbb4 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -1366,7 +1366,7 @@ <string name="msg_data_detached_unsupported">"Unsupported type of detached signature!"</string> <string name="msg_data_error_io">"Error reading input data!"</string> <string name="msg_data_error_openpgp">"Error processing OpenPGP data!"</string> - <string name="msg_data_mime_error">"Error parsing MIME data!"</string> + <string name="msg_data_mime_bad">"Could not parse as MIME data"</string> <string name="msg_data_mime_filename">"Filename: '%s'"</string> <string name="msg_data_mime_length">"Content-Length: %s"</string> <string name="msg_data_mime">"Parsing MIME data structure"</string> |