Bug 13139 - xdg-email fails with unicode strings if using gawk
Summary: xdg-email fails with unicode strings if using gawk
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-07 20:23 UTC by Nigel Liang
Modified: 2011-08-12 07:05 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch suggested by Lei Zhang (243 bytes, text/x-patch)
2007-11-08 11:46 UTC, Nigel Liang
Details
re-diffed patch (600 bytes, patch)
2011-08-12 06:49 UTC, Tomas Bzatek
Details | Splinter Review

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.