-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect mimetype inferrence #8048
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and seems to work. Thank you!
@@ -8,6 +8,7 @@ | |||
|
|||
public class MimeTypeUtil { | |||
public static final String DEFAULT_ATTACHMENT_MIME_TYPE = "application/octet-stream"; | |||
public static final String PLAIN_TEXT_MIME_TYPE = "text/plain"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…etype fix incorrect mimetype inferrence (cherry picked from commit 63cefda)
The problem described in #8045 is different from the one that is addressed by this pull request. I tried to describe what is causing the problem in issue #8045 in this comment. This change does what the pull request description says it does. However, emails that use the wrong MIME type (other than Email clients shouldn't try to be clever and silently "fix" this (Thunderbird on desktop doesn't). Doing this would just lead to more broken messages because people writing software to create such messages will often test the output of their software with a single email client and conclude they did it correctly because it's working with that one email client. If that happens often enough every email client has to implement this non-standard behavior to be compatible with message that can be found in the wild. Unfortunately, I've seen similar cases like this in the past. It's not just a theoretical problem. So we're going to revert this change. But even without this change you should still be able to open PDF attachments that use a MIME type of |
An android app must set the mime type correctly before opening an attachment so it opens with the right app.
However, in the current implementation, K-9 checks the received mimetype from the server, if it's different from the default
application/octet-stream
, it tries to infer it from file extension. But I was able to find in my inbox emails where pdf files are tagged by defaulttext/plain
from the sender, what makes thunderbird open them as text, and thus any app will fail to open the file.Issue #8045 also describes the same problem.
As a result, this commit makes K-9 also treat
text/plain
as a default mimetype too, so it forces it to try infer the type automatically from file extension, what fixes the issueCloses #8045