Closed Bug 743579 Opened 8 years ago Closed 8 years ago

-mail failes with attachments with filename containing commas

Categories

(Thunderbird :: Message Compose Window, defect)

11 Branch
x86
Windows Vista
defect
Not set

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 432315

People

(Reporter: raanan, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20120407 Firefox/13.0a2
Build ID: 20120407042010

Steps to reproduce:

Relevant to Windows (XP, Vista & 7).

The statement below was generated by an application so that Thnderbird composer would be opened with the file 'John, Lucy.jpg' already attached.

"C:\Program Files\Mozilla Thunderbird\thunderbird.exe - mail -compose attachment='"file:///D:\Folder\John, Lucy.jpg"'"


Actual results:

TB reports 'File:///D:\Folder\John does not exist and cannot be attached to the message.'

Evidently the file does not exist, the filename was chopped after the comma.




Expected results:

A comma is a legal character for Windows, Osx, Unix, and as such should be accepted so the filename is not chopped.

If the comma is replaced by a space, there is no problem, which shows that the application generates a correct statement.
See http://kb.mozillazine.org/Command_line_arguments_-_Thunderbird for the expected syntax. There is obviously an ambiguity in the use of the ',' character as it also separates multiple attachments. Thus, you'd need to write it as %2C instead, which is the hex ASCII encoding of the comma character.

Also, in a "file:" URL you should use forward-'/' slashes, not back-'\' slashes, which are specific to Windows path names only.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 432315
(In reply to rsx11m from comment #1)
> See http://kb.mozillazine.org/Command_line_arguments_-_Thunderbird for the
> expected syntax. There is obviously an ambiguity in the use of the ','
> character as it also separates multiple attachments. Thus, you'd need to
> write it as %2C instead, which is the hex ASCII encoding of the comma
> character.
> 
> Also, in a "file:" URL you should use forward-'/' slashes, not back-'\'
> slashes, which are specific to Windows path names only.
> 
> *** This bug has been marked as a duplicate of bug 432315 ***

Replacing the commas with %2C works fine.

As for the syntax, two remarks:
1. The example in the link uses the back slash (attachment='C:\temp\info.doc,C:\temp\food.doc') and actually it works. An application can use the separator which is natural for the environment, and TB will understand.

2. The rules in https://developer.mozilla.org/en/Command_Line_Options specify:
'Command parameters containing spaces must be enclosed in quotes; for example, "Joel User".'

In my example, filename contains spaces, so it is enclosed in quotes, and TB understands that if there are no commas. However, TB should ignore commas within a pair of quotes. 

The use of quotes in command parameters can be avoided if the spaces are replaced by %20. But replacing commas with %2c and spaces with %20 would not be needed if TB processing of quoted parameters was in line with the specification. 

For me there is a bug inasmuch as TB does not comply with the rules in https://developer.mozilla.org/en/Command_Line_Options, which should resolve the issues of commas and of spaces within TB and not transfer the solution to the application.
(In reply to Raanan Barzel from comment #2)
> (attachment='C:\temp\info.doc,C:\temp\food.doc') and actually it works.

The command-line option accepts both the native style of the operating system and the standardized "file:" URLs, thus either works but needs to be consistent.

> In my example, filename contains spaces, so it is enclosed in quotes, and TB
> understands that if there are no commas. However, TB should ignore commas
> within a pair of quotes. 

The problem is that there are two levels of quoting here, so the single quotes are needed to group multiple items in the same category (to='x,y',attachment='a,b') and the entire argument is put into double quotes. The developers' documentation doesn't contradict that, there is actually an example for this specific case mirroring what's stated in the KB article.
(In reply to rsx11m from comment #3)
> (In reply to Raanan Barzel from comment #2)
> > (attachment='C:\temp\info.doc,C:\temp\food.doc') and actually it works.
> 
> The command-line option accepts both the native style of the operating
> system and the standardized "file:" URLs, thus either works but needs to be
> consistent.
> 
> > In my example, filename contains spaces, so it is enclosed in quotes, and TB
> > understands that if there are no commas. However, TB should ignore commas
> > within a pair of quotes. 
> 
> The problem is that there are two levels of quoting here, so the single
> quotes are needed to group multiple items in the same category
> (to='x,y',attachment='a,b') and the entire argument is put into double
> quotes. The developers' documentation doesn't contradict that, there is
> actually an example for this specific case mirroring what's stated in the KB
> article.

With the current version of TB, the entire argument is not put into double quotes; only the path to the excutable is enclosed within double quotes.

Single quotes group multiple items, and each item containing spaces should be enclosed within double quotes. This would give, if a and b contain spaces:

attachment='"a","b"'

The full command line would be:

"C:\Program Files\TB\thunderbird.exe" -compose attachment='"a","b"'

This is consistent with both specs, and TB knows how to process this with regards to spaces.

TB should accept commas within a and b when a and b are each enclosed within double quotes, and not consider them as separators. There is no ambiguity whatsoever, just something left out.
You need to log in before you can comment on or make changes to this bug.