Bug 13139

Summary: xdg-email fails with unicode strings if using gawk
Product: Portland Reporter: Nigel Liang <ncliang>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: bugs
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Patch suggested by Lei Zhang
re-diffed patch

Description Nigel Liang 2007-11-07 20:23:24 UTC
Hi,

The following command brings up a mail composition dialog with blank subject instead of the subject 안 as expected on my system with gawk installed:

xdg-email aaa@aaa.com --subject "안"

However, this works fine on systems that use mawk (such as Feisty). The problem is within the awk code embedded in the url_encode function:

-- snip --
for ( i=1; i<=length ($0); ++i ) {
    c = substr ($0, i, 1)
    if ( ord [c] > 127 ) {
-- snip --

In gawk, string manipulation functions such as length are unicode-aware and return the number of unicode characters instead of the number of bytes. This would usually be a good thing, but in this case the unicode character should be broken up into bytes to be encoded properly. 

Setting LANG and LC_ALL to C right before this snippet tricks awk into thinking the string is ascii and processes it accordingly.
Comment 1 Nigel Liang 2007-11-08 11:46:58 UTC
Created attachment 12408 [details]
Patch suggested by Lei Zhang
Comment 2 Tomas Bzatek 2011-08-12 06:49:51 UTC
Created attachment 50159 [details] [review]
re-diffed patch

Confirming, came across this issue when testing attaching PDF file with extended characters in the name:

> $ XDG_UTILS_DEBUG_LEVEL=99 ./xdg-email ... --attach /tmp/Nabídkový_rozpočet_vše.pdf
> Running thunderbird -compose "....,attachment='file:///tmp/Nab%EDdkov%FD%5Frozpočet%5Fvše.pdf'"

Attaching re-diffed patch.
Comment 3 Tomas Bzatek 2011-08-12 06:51:45 UTC
Forgot to tell that my system locale is "en_US.utf8" as a standard nowadays.
Comment 4 Rex Dieter 2011-08-12 07:05:06 UTC
Thanks!

commit 66537d6ac9d44e14e91ccca77536345338af0e62
Author: Rex Dieter <rdieter@fedoraproject.org>
Date:   Fri Aug 12 09:04:33 2011 -0500

    * xdg-email fails with unicode strings if using gawk (BR13139)

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.