diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java
index 2f81f030b4..dd42830484 100644
--- a/app/src/main/java/eu/faircode/email/MessageHelper.java
+++ b/app/src/main/java/eu/faircode/email/MessageHelper.java
@@ -32,6 +32,7 @@ import android.os.Build;
import android.provider.CalendarContract;
import android.provider.ContactsContract;
import android.system.ErrnoException;
+import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
@@ -3792,12 +3793,19 @@ public class MessageHelper {
class PartHolder {
Part part;
ContentType contentType;
+ String filename;
PartHolder(Part part, ContentType contentType) {
this.part = part;
this.contentType = contentType;
}
+ PartHolder(Part part, ContentType contentType, String filename) {
+ this.part = part;
+ this.contentType = contentType;
+ this.filename = filename;
+ }
+
boolean isPlainText() {
return "text/plain".equalsIgnoreCase(contentType.getBaseType());
}
@@ -3811,7 +3819,10 @@ public class MessageHelper {
}
boolean isPatch() {
- return "text/x-diff".equalsIgnoreCase(contentType.getBaseType()) ||
+ String ext = Helper.getExtension(filename);
+ return "diff".equalsIgnoreCase(ext) ||
+ "patch".equalsIgnoreCase(ext) ||
+ "text/x-diff".equalsIgnoreCase(contentType.getBaseType()) ||
"text/x-patch".equalsIgnoreCase(contentType.getBaseType());
}
@@ -4239,7 +4250,10 @@ public class MessageHelper {
result = HtmlHelper.formatPlainText(result);
}
} else if (h.isPatch()) {
+ String filename = h.part.getFileName();
result = (first ? "" : "
" + HtmlHelper.formatPlainText(result) + ""; @@ -5382,10 +5396,13 @@ public class MessageHelper { filename += ".html"; } + String ext = Helper.getExtension(filename); if ("text/markdown".equalsIgnoreCase(ct) || "text/x-diff".equalsIgnoreCase(ct) || - "text/x-patch".equalsIgnoreCase(ct)) - parts.extra.add(new PartHolder(part, contentType)); + "text/x-patch".equalsIgnoreCase(ct) || + "diff".equalsIgnoreCase(ext) || + "patch".equalsIgnoreCase(ext)) + parts.extra.add(new PartHolder(part, contentType, filename)); if (Report.isDeliveryStatus(ct) || Report.isDispositionNotification(ct) ||