Normalize attachments

This commit is contained in:
M66B 2021-09-05 19:37:45 +02:00
parent 26c9312c96
commit 21457f908c
2 changed files with 20 additions and 1 deletions

View File

@ -265,7 +265,7 @@ public class ActivityEML extends ActivityBase {
result.sent = helper.getSent();
result.received = helper.getReceived();
result.subject = helper.getSubject();
result.parts = helper.getMessageParts();
result.parts = helper.getMessageParts(false);
String html = result.parts.getHtml(context);
if (html != null) {

View File

@ -1938,6 +1938,18 @@ public class MessageHelper {
return false;
}
void normalize() {
Boolean plain = isPlainOnly();
if (plain == null || plain)
for (AttachmentPart apart : attachments)
if (!TextUtils.isEmpty(apart.attachment.cid) ||
!Part.ATTACHMENT.equals(apart.attachment.disposition)) {
Log.i("Normalizing " + apart.attachment);
apart.attachment.cid = null;
apart.attachment.disposition = Part.ATTACHMENT;
}
}
Long getBodySize() throws MessagingException {
Long size = null;
@ -2542,6 +2554,10 @@ public class MessageHelper {
}
MessageParts getMessageParts() throws IOException, MessagingException {
return getMessageParts(true);
}
MessageParts getMessageParts(boolean normalize) throws IOException, MessagingException {
MessageParts parts = new MessageParts();
try {
@ -2678,6 +2694,9 @@ public class MessageHelper {
*/
}
if (normalize)
parts.normalize();
return parts;
}