Fix incorrect mimetype inferrence by Mino260806 · Pull Request #8048 · thunderbird/thunderbird-android · GitHub
Skip to content
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

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

Mino260806
Copy link
Contributor

@Mino260806 Mino260806 commented Aug 3, 2024

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 default text/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 issue


Closes #8045

Copy link
Member

@wmontwe wmontwe left a 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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wmontwe wmontwe changed the title fix incorrect mimetype inferrence Fix incorrect mimetype inferrence Aug 6, 2024
@wmontwe wmontwe merged commit 63cefda into thunderbird:main Aug 6, 2024
2 checks passed
@wmontwe wmontwe added the task: backport Backport to the latest stable version once the code got some exposure in beta label Aug 7, 2024
wmontwe added a commit to wmontwe/thunderbird-android that referenced this pull request Aug 8, 2024
…etype

fix incorrect mimetype inferrence

(cherry picked from commit 63cefda)
@wmontwe wmontwe removed the task: backport Backport to the latest stable version once the code got some exposure in beta label Aug 8, 2024
@cketti
Copy link
Member

cketti commented Aug 22, 2024

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 application/octet-stream that can be used as a fall-back when no concrete MIME type is known) for an attachment are broken.

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 text/plain by saving the attachment first, then opening it using a file manager or the PDF viewer directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send the file name with extension when sharing/opening to another app
3 participants