1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Convert large bodies to attachments

This commit is contained in:
M66B 2023-03-01 08:20:53 +01:00
parent 190f3b2293
commit aadd95595f

View file

@ -3310,6 +3310,7 @@ public class MessageHelper {
parts.addAll(extra);
for (PartHolder h : parts) {
/*
int size = h.part.getSize();
if (size > 100 * 1024 * 1024)
Log.e("Unreasonable message size=" + size);
@ -3317,6 +3318,7 @@ public class MessageHelper {
warnings.add(context.getString(R.string.title_insufficient_memory, size));
return null;
}
*/
if (Boolean.parseBoolean(System.getProperty("fairemail.preamble"))) {
String preamble = h.contentType.getParameter("preamble");
@ -4657,6 +4659,13 @@ public class MessageHelper {
filename = null;
}
int size = Integer.MAX_VALUE;
try {
size = part.getSize();
} catch (MessagingException ex) {
Log.w(ex);
}
ContentType contentType;
try {
// From the body structure
@ -4671,7 +4680,8 @@ public class MessageHelper {
String ct = contentType.getBaseType();
if (("text/plain".equalsIgnoreCase(ct) || "text/html".equalsIgnoreCase(ct)) &&
!Part.ATTACHMENT.equalsIgnoreCase(disposition) && TextUtils.isEmpty(filename)) {
!Part.ATTACHMENT.equalsIgnoreCase(disposition) && TextUtils.isEmpty(filename) &&
(size <= MAX_MESSAGE_SIZE || size == Integer.MAX_VALUE)) {
parts.text.add(new PartHolder(part, contentType));
} else {
// Workaround for NIL message content type
@ -4682,6 +4692,16 @@ public class MessageHelper {
parts.text.add(new PartHolder(part, plain));
}
if (("text/plain".equalsIgnoreCase(ct) || "text/html".equalsIgnoreCase(ct)) &&
TextUtils.isEmpty(Helper.getExtension(filename))) {
if (TextUtils.isEmpty(filename))
filename = "body";
if ("text/plain".equalsIgnoreCase(ct))
filename += ".txt";
if ("text/html".equalsIgnoreCase(ct))
filename += ".html";
}
if (Report.isDeliveryStatus(ct) ||
Report.isDispositionNotification(ct) ||
Report.isFeedbackReport(ct))