Open Bug 1755454 Opened 3 years ago Updated 10 months ago

Unable to open .eml from file:// uri

Categories

(Thunderbird :: General, defect, P5)

Thunderbird 91

Tracking

(Not tracked)

REOPENED

People

(Reporter: manikulin, Assigned: u695164)

References

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0

Steps to reproduce:

I can not open a mail message fetched using browser namely as mail message, instead new message is created with the specified file as an attachment.

Consider the following use case: reply to particular comment to a bug from https://debbugs.gnu.org This bug tracker uses mail interface to accept new reports or comments. For convenience of other participants it is better to compose a message with proper In-Reply-To header.

Actual results:

Thunderbird opens compose window with the file containing mail message as attachment.

The download has proper MIME type:

curl -I 'https://debbugs.gnu.org/cgi/bugreport.cgi?msg=50;bug=40959;mbox=yes'
HTTP/1.1 200 OK
Date: Mon, 14 Feb 2022 10:53:37 GMT
Server: Apache
Content-disposition: attachment; filename="bug_40959_message_50.mbox"
Strict-Transport-Security: max-age=63072000
Last-Modified: Fri, 05 Jun 2020 11:24:05 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
Content-Type: message/rfc822

However it becomes an ordinary text file as soon as it is downloaded to disk:

file bug_40959_message_50.mbox 
bug_40959_message_50.mbox: UTF-8 Unicode text

I have tried various options to open file. Error messages are given for daily build 99a1

Variants: silent failure, a message in the console:

thunderbird bug_40959_message_50.mbox
thunderbird file://`pwd`/bug_40959_message_50.mbox
thunderbird --file bug_40959_message_50.mbox
NS_ERROR_FAILURE: MessengerContentHandler.jsm:80
    openURI resource:///modules/MessengerContentHandler.jsm:80
    handle resource:///modules/MessengerContentHandler.jsm:553

With absolute path but without explicit file:// scheme compose window appears with the file attached:

thunderbird `pwd`/bug_40959_message_50.mbox
thunderbird --file `pwd`/bug_40959_message_50.mbox

Main window with folder is raised and activated and an error is reported to the console if --mail option is used:

thunderbird --mail bug_40959_message_50.mbox
 Unrecognized URL: bug_40959_message_50.mbox

thunderbird --mail `pwd`/bug_40959_message_50.mbox
 Unrecognized URL: /home/ubuntu/bug_40959_message_50.mbox

thunderbird --mail file://`pwd`/bug_40959_message_50.mbox
 Unrecognized URL: file:///home/ubuntu/bug_40959_message_50.mbox

Expected results:

  • There should be a command line option that forces opening a file as mail message bypassing heuristics.
  • Some error message should be shown to user if thunderbird can not handle specified option and argument.
  • file:// scheme should not cause an error, the URI should be considered as a local file.

Workaround: rename file to give it .eml extension instead of .mbox and open it as a relative or absolute path. Warning: do not add explicit file:// scheme otherwise it fails with the following message:

thunderbird file://`pwd`/bug_40959_message_50.eml
 NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsICommandLine.resolveFile]

mbox is not the same as .eml (mbox could be many messages, we should not open those this way).
But I agree if the file:// url ends with .eml we could resolve that as a file and open as well.
I think Services.io.newURI(uri).QueryInterface(Ci.nsIFileURL).file should do it

https://searchfox.org/comm-central/rev/a6df383cab9a777bf3b763da76ced1fe3efd8b22/mail/components/MessengerContentHandler.jsm#365

Assignee: nobody → nicolai
Status: UNCONFIRMED → NEW
Component: Untriaged → General
Ever confirmed: true
Summary: Unable to force open file as a mail message → Unable to open .eml from file:// uri

(In reply to Magnus Melin [:mkmelin] from comment #1)

mbox is not the same as .eml (mbox could be many messages, we should not open those this way).

I am asking for an option that explicitly tells thunderbird that some file is namely a mail message. I do not mind to get error it there are actually several messages in such file.

There should be a way to override decision based on file suffix. Why it should not be possible to to compose a message with an .eml file as its attachment?

You implicitly states that FSF version of debbugs has a bug since it sends file name with .mbox extension, but it must be .eml.

Instead of just click on a link, thunderbird users have to download, rename the file to allow proper handling of the file. On Linux actual MIME type is often more important than file extension. Unfortunately this is a case when both .mbox and .eml are just text, so libmagic can not discriminate them.

Another case. git format-patch generates files with .patch suffix. It would be nice to just send them without text rewrapping using SMTP settings in thunderbird when SMTP is not configured for git. However sometimes it is preferable to send the same .patch file as an attachment. Both options should be supported.

P.S. It is a loosely related feature request, but when thunderbird opens a file with a collection of mail messages it would be nice to get mail folder representation with threads (a viewer for .mbox files).

You implicitly states that FSF version of debbugs has a bug since it sends file name with .mbox extension, but it must be .eml.

Yes that is a bug. Or maybe they sometimes include more than one message. I have no experience with it.

(In reply to Magnus Melin [:mkmelin] from comment #3)

You implicitly states that FSF version of debbugs has a bug since it sends file name with .mbox extension, but it must be .eml.

Yes that is a bug. Or maybe they sometimes include more than one message. I have no experience with it.

The link and the log I provided are for particular comment that is a single message. At the top of the page there are links for all messages related to that bug:

curl -I 'https://debbugs.gnu.org/cgi/bugreport.cgi?mbox=yes;bug=40959'
HTTP/1.1 200 OK
Date: Tue, 15 Feb 2022 14:52:03 GMT
Server: Apache
Content-disposition: attachment; filename="bug_40959.mbox"
Strict-Transport-Security: max-age=63072000
Last-Modified: Fri, 05 Jun 2020 11:24:05 GMT
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
Content-Type: text/plain; charset=ISO-8859-1

The extension is the same: .mbox, but Content-Type is different. Debian version of debbugs sends application/mbox for whole bug discussion and .mbox extension for both single message and for all comments.

So there are both types and browser may launch different handlers for single message and for mailbox with several messages.

Concerning file:// scheme, it may be used to specify particular message in "Local Folders". Handling of file:// scheme with "guess what I mean" approach might cause security issues. E.g. files might be remote file://host/path.

Could you, please, clarify what is the purpose of the -file command line option? I can not found a definitive reference. Output of --help is rather brief and -file option there has no argument at all unlike e.g. -mail. Support page https://support.mozilla.org/bm/questions/1264202 points to kb.mozillazine.org.

To attach a file to a new message, it seems there is an explicit way: -compose attachment=FILE.

"File" -> "Open" -> "Open saved message" allows to relax suffix filter and to open .mbox or .patch file. Even multi-message mbox file can be opened is such way, and it is acceptable that everything after first message is considered as its body. Why a similar option is not available from command line (to allow integration with other applications)?

Flags: needinfo?(mkmelin+mozilla)

perhaps -file is obsolete, because it is not isted at https://udn.realityripple.com/docs/Mozilla/Command_Line_Options

Looks obsolete yes. The -options arg seems like it should go as well. We don't have an options dialog since ages. What it does atm is weird...

Flags: needinfo?(mkmelin+mozilla)
Status: NEW → ASSIGNED

(In reply to Magnus Melin [:mkmelin] from comment #7)

Looks obsolete yes. The -options arg seems like it should go as well. We don't have an options dialog since ages. What it does atm is weird...

I have never mentioned -options flag, but I would expect that it opens "Preferences" (item from the hamburger menu) as a tab or as a dedicated window.

To be clear, I can force composing a message with an .eml file as an attachment through

thunderbird -compose attachment=bug_40959_message_50.eml

I am asking for a way to open from command line bug_40959_message_50.mbox to view it as a mail message. It is possible from menu but requires enough extra click especially if the file is just downloaded by a browser to a temporary directory. Existing -file option could do it.

Earlier I created Bug #1754415 to make parsing command line more predictable. See e.g. Bug #384384 for an old vulnerability due to ambiguous treatment of arguments.

See Also: → 1754415

Concerning original request to ignore file suffix when user explicitly requested to open it as a mail message. Let me remind a relatively recent issue that I accidentally noticed. Heuristics were originally considered powerful enough to drop explicit charset selector, but such change caused problems for some users, see follow-ups of the Bug 1687635.

(In reply to Magnus Melin [:mkmelin] from comment #7)

Looks obsolete yes. The -options arg seems like it should go as well. We don't have an options dialog since ages. What it does atm is weird...

Firefox has the --preferences option and it opens a settings tab.

Priority: -- → P5
Severity: -- → N/A
Status: ASSIGNED → NEW

FYI: I'm currently prioritized on something else, but we are taking care to get this done.

Resolved in bug 1816343

Status: NEW → RESOLVED
Closed: 10 months ago
Duplicate of bug: 1816343
Resolution: --- → DUPLICATE

Sorry, but bug 1816343 is another loosely related issue, not the one I reported.

I just have tried thunderbird 1:115.4.1-1~deb12u1 from Debian 12 bookworm.

Effect of

thunderbird 'file:///tmp/bug_40959_message_50.mbox'

is a compose window with bug_40959_message_50.mbox file treated as an attachment. As I wrote in the comment #5, it was possible earlier using -compose attachment=FILE.

I requested a way to open mail messages from CLI as it can be done using File → Open → Open Saved message… menu option. I still see no way to explicitly express that I want to open namely a mail message bypassing any heuristics.

Status: RESOLVED → REOPENED
No longer duplicate of bug: 1816343
Resolution: DUPLICATE → ---
You need to log in before you can comment on or make changes to this bug.