[xdg-email] Percent encoding problems
Michael Bäuerle
michael.baeuerle at stz-e.de
Mon Aug 25 01:34:47 PDT 2014
Rex Dieter wrote:
> Rex Dieter wrote:
> > Michael Bäuerle wrote:
> > >
> > > The problem is that the '-' character is used literally inside a regex
> > > bracket expression (where it has the meaning of a range, like in "a-z"),
> > > look at [3] (Paragraph 7) for the syntax definition.
> > > The resulting range spans over the '?' character and prevents its
> > > percent encoding.
> >
> > Testing myself, I cannot reproduce the problem you describe. Can you give
> > a reproducible example?
> >
> > I tried:
> >
> > xdg-email rdieter-foo at bar.com
> >
> > and my email client opens correctly (with rdieter-foo at bar.com as expected,
> > instead of something percent-encoded as you suggested would happen).
> >
> > Fwiw, it happens the same for me whether I include your suggested fix or
> > not.
>
> My mail client testing this (thunderbird) was handling the percent-encoded
> input for me :-/
>
> After adding some extra debugging I do see that unpatched code was passing
> on:
> mailto:rdieter%2Dfoo at bar.com
>
> Which mail client(s) did you use that didnt handle this?
I got a report from a user where the "-" don't work with Thunderbird
on an Ubuntu system. Don't ask me why Thunderbird don't like it. And
yes, your example above is valid and it is the fault of Thunderbird to
not decode it correctly.
The reason why I reported the problem is that it's not the intent of
xdg-email to encode the '-' (the missing backslash). Letting awk
interpret the backslash as range breaks the encoding of some characters
inside the range that are not allowed to appear literally. And this is
a bug in xdg-email, see below.
I use claws-mail without a desktop environment. Therefore I have created
a 'xdg-email-hook.sh' script with the following content:
----------------------------------------------------------------------
#! /bin/sh
echo "xdg-email-hook: $1"
claws-mail $1
----------------------------------------------------------------------
The echo show me (without the backslash-patch):
----------------------------------------------------------------------
$ xdg-email --utf8 'rdieter-foo at bar.com'
xdg-email-hook: mailto:rdieter%2Dfoo at bar.com
$ xdg-email --utf8 'rdieter?foo at bar.com'
xdg-email-hook: mailto:rdieter?foo at bar.com
----------------------------------------------------------------------
The first example is valid (as stated above), but the second is
invalid. Both ('-' and '?') are allowed to be part of the local-part of
an addr-spec according to RFC5322. But a literal '?' is not allowed to
be part of an URI (with this meaning) according to RFC2368.
As a result claws-mail correctly truncates the address and show
"rdieter" in the address field instead of "rdieter?foo at bar.com".
With the backslash-patch it works as expected (and IMHO intended by the
authors of xdg-email because the '-' don't need percent encoding):
---------------------------------------------------------------------
$ xdg-email --utf8 'rdieter-foo at bar.com'
xdg-email-hook: mailto:rdieter-foo at bar.com
$ xdg-email --utf8 'rdieter?foo at bar.com'
xdg-email-hook: mailto:rdieter%3Ffoo at bar.com
---------------------------------------------------------------------
That the '-' now works for the noted Thunderbird user too is a nice
side effect.
This example shows why the '?' is reserved by RFC2368 and must be
percent encoded:
---------------------------------------------------------------------
$ xdg-email --utf8 --subject 'test' 'rdieter?foo at bar.com'
xdg-email-hook: mailto:rdieter%3Ffoo at bar.com?subject=test
---------------------------------------------------------------------
More information about the xdg
mailing list