[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#966286: xdg-email (as used in nemo-data, where 'Send by email' misbehaves when parent's folder name contains a comma.)



I'm happy to report that I think I found the problem and a solution for 966286@bugs.debian.org aka  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=966286

When you call `/usr/bin/thunderbird`, one must separate optional attachments with a comma.   See:  http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29 which has this example:

Notice the comma in the last part:  ... 'C:\temp\info.doc,C:\temp\food.doc

This page also says that you can specify these attachment file(s) with either absolute filenames or encoded URLs. 

But if you specify absolute filenames, then any comma, in any one of these filenames, or in their paths, creates a problem because it's unescaped. 


So to fix this bug the xdg-email shell script needs to be changed to call Thunderbird with an encoded URL rather than an absolute filename.  Fortunately this is fairly easy to do with the following single line change which had incorrectly un-encoded the attachment name, rather than keep and use the encoding to form a URL:

ATTACH=$(/bin/echo -e $(echo "$MAILTO" | grep '^attach='     | sed 's/^attach=//;s/%\(..\)/\\x\1/g'     | awk '{ printf "%s,",$0 }' | sed 's/,$//'    ))    #was
ATTACH=$(/bin/echo -e $(echo "$MAILTO" | grep '^attach='     | sed 's/^attach=//;s|^|file://|g'             | awk '{ printf "%s,",$0 }' | sed 's/,$//'    ))    #should be


Note that in our case there is only one path/filename, so this could be further simplified as follows:

ATTACH=$(/bin/echo -e $(echo "$MAILTO" | grep '^attach='     | sed 's/^attach=//;s|^|file://|g'                                                                                  ))     #could also be


BTW, here's the line I'm using to test it:

    $ xdg-email --attach /usr/share/nemo/actions/foo,bar/x

where 'foo, bar' is a folder name with a file named x in it.

Hope this makes sense.

Thanks for writing this Kevin and JWhite!


Reply to: