Check multiparts

pull/196/head
M66B 5 years ago
parent f3cc91fb65
commit 41ef956695

@ -2372,57 +2372,65 @@ public class MessageHelper {
if ("application/pgp-signature".equals(protocol) || if ("application/pgp-signature".equals(protocol) ||
"application/pkcs7-signature".equals(protocol) || "application/pkcs7-signature".equals(protocol) ||
"application/x-pkcs7-signature".equals(protocol)) { "application/x-pkcs7-signature".equals(protocol)) {
Multipart multipart = (Multipart) part.getContent(); Object content = part.getContent();
if (multipart.getCount() == 2) { if (content instanceof Multipart) {
getMessageParts(multipart.getBodyPart(0), parts, null); Multipart multipart = (Multipart) content;
getMessageParts(multipart.getBodyPart(1), parts, if (multipart.getCount() == 2) {
"application/pgp-signature".equals(protocol) getMessageParts(multipart.getBodyPart(0), parts, null);
? EntityAttachment.PGP_SIGNATURE getMessageParts(multipart.getBodyPart(1), parts,
: EntityAttachment.SMIME_SIGNATURE); "application/pgp-signature".equals(protocol)
? EntityAttachment.PGP_SIGNATURE
AttachmentPart apart = new AttachmentPart(); : EntityAttachment.SMIME_SIGNATURE);
apart.disposition = Part.INLINE;
apart.filename = "content.asc"; AttachmentPart apart = new AttachmentPart();
apart.encrypt = "application/pgp-signature".equals(protocol) apart.disposition = Part.INLINE;
? EntityAttachment.PGP_CONTENT apart.filename = "content.asc";
: EntityAttachment.SMIME_CONTENT; apart.encrypt = "application/pgp-signature".equals(protocol)
apart.part = part; ? EntityAttachment.PGP_CONTENT
: EntityAttachment.SMIME_CONTENT;
apart.attachment = new EntityAttachment(); apart.part = part;
apart.attachment.disposition = apart.disposition;
apart.attachment.name = apart.filename; apart.attachment = new EntityAttachment();
apart.attachment.type = "text/plain"; apart.attachment.disposition = apart.disposition;
apart.attachment.size = getSize(); apart.attachment.name = apart.filename;
apart.attachment.encryption = apart.encrypt; apart.attachment.type = "text/plain";
apart.attachment.size = getSize();
parts.attachments.add(apart); apart.attachment.encryption = apart.encrypt;
return parts; parts.attachments.add(apart);
} else {
StringBuilder sb = new StringBuilder(); return parts;
sb.append(ct); } else {
for (int i = 0; i < multipart.getCount(); i++) StringBuilder sb = new StringBuilder();
sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType()); sb.append(ct);
Log.e(sb.toString()); for (int i = 0; i < multipart.getCount(); i++)
} sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType());
Log.e(sb.toString());
}
} else
throw new MessagingException("Multipart=" + (content == null ? null : content.getClass().getName()));
} else } else
Log.e(ct.toString()); Log.e(ct.toString());
} else if (part.isMimeType("multipart/encrypted")) { } else if (part.isMimeType("multipart/encrypted")) {
ContentType ct = new ContentType(part.getContentType()); ContentType ct = new ContentType(part.getContentType());
String protocol = ct.getParameter("protocol"); String protocol = ct.getParameter("protocol");
if ("application/pgp-encrypted".equals(protocol) || protocol == null) { if ("application/pgp-encrypted".equals(protocol) || protocol == null) {
Multipart multipart = (Multipart) part.getContent(); Object content = part.getContent();
if (multipart.getCount() == 2) { if (content instanceof Multipart) {
// Ignore header Multipart multipart = (Multipart) content;
getMessageParts(multipart.getBodyPart(1), parts, EntityAttachment.PGP_MESSAGE); if (multipart.getCount() == 2) {
return parts; // Ignore header
} else { getMessageParts(multipart.getBodyPart(1), parts, EntityAttachment.PGP_MESSAGE);
StringBuilder sb = new StringBuilder(); return parts;
sb.append(ct); } else {
for (int i = 0; i < multipart.getCount(); i++) StringBuilder sb = new StringBuilder();
sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType()); sb.append(ct);
Log.e(sb.toString()); for (int i = 0; i < multipart.getCount(); i++)
} sb.append(' ').append(i).append('=').append(multipart.getBodyPart(i).getContentType());
Log.e(sb.toString());
}
} else
throw new MessagingException("Multipart=" + (content == null ? null : content.getClass().getName()));
} else } else
Log.e(ct.toString()); Log.e(ct.toString());
} else if (part.isMimeType("application/pkcs7-mime") || } else if (part.isMimeType("application/pkcs7-mime") ||

Loading…
Cancel
Save