diff --git a/app/src/main/java/eu/faircode/email/EntityAttachment.java b/app/src/main/java/eu/faircode/email/EntityAttachment.java index 966d093dd6..08c5937fad 100644 --- a/app/src/main/java/eu/faircode/email/EntityAttachment.java +++ b/app/src/main/java/eu/faircode/email/EntityAttachment.java @@ -155,6 +155,9 @@ public class EntityAttachment { String getMimeType() { // Try to guess a better content type // For example, sometimes PDF files are sent as application/octet-stream + // https://android.googlesource.com/platform/libcore/+/refs/tags/android-9.0.0_r49/luni/src/main/java/libcore/net/MimeUtils.java + // https://blogs.msdn.microsoft.com/vsofficedeveloper/2008/05/08/office-2007-file-format-mime-types-for-http-content-streaming-2/ + if (encryption != null) return type; @@ -165,11 +168,17 @@ public class EntityAttachment { String gtype = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(extension.toLowerCase(Locale.ROOT)); - // Some servers erroneously remove dots from mime types - // https://blogs.msdn.microsoft.com/vsofficedeveloper/2008/05/08/office-2007-file-format-mime-types-for-http-content-streaming-2/ - if (gtype != null && - gtype.replace(".", "").equals(type)) - type = gtype; + if (gtype != null) { + if (TextUtils.isEmpty(type) || "*/*".equals(type)) + type = gtype; + + // Some servers erroneously remove dots from mime types + if (gtype.replace(".", "").equals(type)) + type = gtype; + } + + if ("eml".equals(extension)) + return "message/rfc822"; if ("text/plain".equals(type) && "ovpn".equals(extension)) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 0f474bff80..e7234295d7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -2383,7 +2383,7 @@ public class FragmentCompose extends FragmentBase { ftype = null; } - if (TextUtils.isEmpty(ftype)) + if (TextUtils.isEmpty(ftype) || "*/*".equals(ftype)) ftype = Helper.guessMimeType(fname); if (fsize != null && fsize <= 0)