mime: skip trailing unsigned parts, and ignore nested signed data
This commit is contained in:
@@ -146,8 +146,8 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
||||
@Override
|
||||
public void startMultipart(BodyDescriptor bd) throws MimeException {
|
||||
if ("signed".equals(bd.getSubType())) {
|
||||
if (mSignedDataResult != null) {
|
||||
// recursive signed data is not supported!
|
||||
if (mSignedDataUri != null) {
|
||||
// recursive signed data is not supported, and will just be parsed as-is
|
||||
log.add(LogType.MSG_DATA_DETACHED_NESTED, 2);
|
||||
return;
|
||||
}
|
||||
@@ -185,6 +185,7 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
||||
}
|
||||
|
||||
out.close();
|
||||
// continue to next body part the usual way
|
||||
parser.setFlat();
|
||||
|
||||
}
|
||||
@@ -259,6 +260,13 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
||||
return;
|
||||
}
|
||||
|
||||
// If mSignedDataUri is non-null, we already parsed a signature. If mSignedDataResult is non-null
|
||||
// too, we are still in the same parsing stage, so this is trailing data - skip it!
|
||||
if (mSignedDataUri != null && mSignedDataResult != null) {
|
||||
log.add(LogType.MSG_DATA_DETACHED_TRAILING, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
log.add(LogType.MSG_DATA_MIME_PART, 2);
|
||||
|
||||
log.add(LogType.MSG_DATA_MIME_TYPE, 3, bd.getMimeType());
|
||||
@@ -313,8 +321,13 @@ public class InputDataOperation extends BaseOperation<InputDataParcel> {
|
||||
decryptResult = mSignedDataResult;
|
||||
}
|
||||
|
||||
in = mContext.getContentResolver().openInputStream(mSignedDataUri);
|
||||
// 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 we found data, return success
|
||||
|
||||
@@ -835,6 +835,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_DATA_DETACHED_SIG (LogLevel.DEBUG, R.string.msg_data_detached_sig),
|
||||
MSG_DATA_DETACHED_RAW (LogLevel.DEBUG, R.string.msg_data_detached_raw),
|
||||
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_FILENAME (LogLevel.DEBUG, R.string.msg_data_mime_filename),
|
||||
|
||||
@@ -1362,6 +1362,7 @@
|
||||
<string name="msg_data_detached_sig">"Processing detached signature"</string>
|
||||
<string name="msg_data_detached_raw">"Processing signed data"</string>
|
||||
<string name="msg_data_detached_nested">"Skipping nested signed data!"</string>
|
||||
<string name="msg_data_detached_trailing">"Skipping trailing data after signed part!"</string>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user