Bug 91996 - xdg-email: Recipients passed to Thunderbird are incorrectly quoted
Summary: xdg-email: Recipients passed to Thunderbird are incorrectly quoted
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-09-14 05:52 UTC by Per Olofsson
Modified: 2015-09-18 14:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
xdg-email-thunderbird-quoting.patch (1.83 KB, text/plain)
2015-09-14 05:52 UTC, Per Olofsson
Details
xdg-email-thunderbird-quoting-2.patch (1.42 KB, patch)
2015-09-14 06:09 UTC, Per Olofsson
Details | Splinter Review

Description Per Olofsson 2015-09-14 05:52:13 UTC
Created attachment 118253 [details]
xdg-email-thunderbird-quoting.patch

For example, if I run:

  xdg-email --to pelle@debian.org

Thunderbird opens a compose window with the To field set to 'pelle@debian.org <>'. I.e., it tries to e-mail somebody whose name is "pelle@debian.org" but with an empty e-mail address.

The problem is that xdg-email quotes the recipient fields (even with BOTH single and double quotes!). Removing the quotes fixes the problem. I have attached a patch to do just that.

It might be the case that older versions of TB need the quotes (I run Thunderbird (Icedove) 40.0). If anyone knows which versions need the quotes I could implement a check for that.
Comment 1 Per Olofsson 2015-09-14 06:09:50 UTC
Created attachment 118255 [details] [review]
xdg-email-thunderbird-quoting-2.patch

Apparently the single quotes are needed for multiple recipients. Here is an new version of the patch.
Comment 2 Rex Dieter 2015-09-16 15:12:15 UTC
Under what circumstances does this fail?

I think we can assume that callers should properly quote (or escape) arguments passed to xdg-email

I suppose we can adopt this assuming the case I mentioned above still works with this change (does it)?
Comment 3 Per Olofsson 2015-09-16 17:53:49 UTC
(In reply to Rex Dieter from comment #2)
> Under what circumstances does this fail?

Not sure exactly what you mean, but without the single quotes this fails:

  xdg-email --to pelle@debian.org --to pelle@dsv.su.se

> I think we can assume that callers should properly quote (or escape)
> arguments passed to xdg-email

Of course. But the single quotes in this case is a Thunderbird peculiarity and not a part of xdg-email's interface.

> I suppose we can adopt this assuming the case I mentioned above still works
> with this change (does it)?

Which case?
Comment 4 Rex Dieter 2015-09-16 18:50:06 UTC
Does these cases still work afterward?

xdg-email --to "pelle@debian.org" --to "pelle@dsv.su.se"
or
xdg-email --to 'pelle@debian.org' --to 'pelle@dsv.su.se'

if so, I have no problem taking in this fix.
Comment 5 Per Olofsson 2015-09-17 02:39:07 UTC
(In reply to Rex Dieter from comment #4)
> Does these cases still work afterward?
> 
> xdg-email --to "pelle@debian.org" --to "pelle@dsv.su.se"
> or
> xdg-email --to 'pelle@debian.org' --to 'pelle@dsv.su.se'
> 
> if so, I have no problem taking in this fix.

Sure. The quotes are interpreted by the shell in these cases and never passed to xdg-email.
Comment 6 Rex Dieter 2015-09-18 12:54:54 UTC
OK, looks like the origins of this goes back to commit,
http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=31c9f61c608433bd38211bd6c68baac393afa983

to handle cases where there was punctuation (like comma's) in email addresses.  I'll try testing both cases.
Comment 7 Rex Dieter 2015-09-18 13:55:43 UTC
This new version of patch doesn't seem to fix things fully, what I see getting sent to thunderbird includes an extra trailing comma,

XDG_UTILS_DEBUG_LEVEL=4 xdg-email --to rdieter@math.unl.edu
...
Running thunderbird -compose "to='rdieter@math.unl.edu,'"

which I think is part of the problem here, digging deeper.
Comment 8 Rex Dieter 2015-09-18 14:26:46 UTC
Looks like the comma at the end is presumably to support multiple --to command line args, which doesn't seem to documented as supported.

this would require one to change from:
xdg-email --to pelle@debian.org --to pelle@dsv.su.se
to
xdg-email --to pelle@debian.org,pelle@dsv.su.se

Would you object if I removed it?
Comment 9 Per Olofsson 2015-09-18 14:39:03 UTC
(In reply to Rex Dieter from comment #6)
> OK, looks like the origins of this goes back to commit,
> http://cgit.freedesktop.org/xdg/xdg-utils/commit/
> ?id=31c9f61c608433bd38211bd6c68baac393afa983
> 
> to handle cases where there was punctuation (like comma's) in email
> addresses.  I'll try testing both cases.

I think the patch author might be confused. This should be the correct way to pass recipients with commas to xdg-email:

  xdg-email --to "\"Per Olofsson, developer\" <pelle@dsv.su.se>"

You always need to quote recipient names with commas, I'm pretty sure that's in the RFC. The outer quotes in this case are for the shell, only the inner quotes are passed to xdg-email.
Comment 10 Per Olofsson 2015-09-18 14:44:21 UTC
(In reply to Rex Dieter from comment #8)
> Looks like the comma at the end is presumably to support multiple --to
> command line args, which doesn't seem to documented as supported.
> 
> this would require one to change from:
> xdg-email --to pelle@debian.org --to pelle@dsv.su.se
> to
> xdg-email --to pelle@debian.org,pelle@dsv.su.se
> 
> Would you object if I removed it?

If it is used by applications, yes I would.

But what about this case:

  xdg-email pelle@debian.org pelle@dsv.su.se

It is clearly documented in the man page. Doesn't it cause the same problem?

Also, I don't get a trailing comma in Thunderbird.
Comment 11 Rex Dieter 2015-09-18 14:50:11 UTC
You see it only if you enable debugging, for example,

XDG_UTILS_DEBUG_LEVEL=4 xdg-email --to "pelle@dsv.su.se"
Running thunderbird -compose "to='pelle@dsv.su.se,'"

but I see now that the appended comma is mostly harmless, and thunderbird ignores it in all valid cases I can find.



Applying the patch now (adjusted for recent other commits, mostly the change from 'echo' to explicit '/bin/echo'):

http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=03577f987730bcbe0a9f25b1f7cb386c8c4ede97

thanks again.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.