Bug 81386 - xdg-utils fails if user sets a custom IFS environment variable
Summary: xdg-utils fails if user sets a custom IFS environment variable
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-15 14:48 UTC by Jehan
Modified: 2014-09-19 17:56 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
xdg-email: reset the IFS before interpreting a shell command. (705 bytes, text/plain)
2014-07-15 14:48 UTC, Jehan
Details

Description Jehan 2014-07-15 14:48:32 UTC
Created attachment 102859 [details]
xdg-email: reset the IFS before interpreting a shell command.

Reproduction:

1/ Set some temporary IFS which is not the default (space). Ex:
$ export IFS=";"

2/ Run the xdg-email command:
$ xdg-email --subject "hello" 'contact@example.com'
/home/jehan/.local/bin/xdg-email: 696: /home/jehan/.local/bin/xdg-email: iconv -t utf8: not found
/home/jehan/.local/bin/xdg-email: 696: /home/jehan/.local/bin/xdg-email: iconv -t utf8: not found

Result: the command fails. The mailer is run, but all parameters are empty (in this example for instance, no subject, not recipient pre-filled.

The reason is line 232 of current git master:
str=$(echo "$1" | $utf8)

In this case, utf8="iconv -t utf8", and if IFS is not the default space character, the shell searches for this string as a whole since it uses the IFS to separate the commands from the parameters. Hence "not found" error.

Easy to reproduce just on the shell:

$ export IFS=";"
$ a="ls -a"
$ $a
ls -a: command not found

Of course playing with the IFS is not everyday, but that can happen when you are coding in the shell and needs to loop through some data formatted some specific way. Better the xdg script be robust against random environments.
Solution is to force back IFS=" " just before. Attached a patch.
Comment 1 Rex Dieter 2014-09-19 17:56:02 UTC
Patch applied, thanks!


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.