Bug 81386

Summary: xdg-utils fails if user sets a custom IFS environment variable
Product: Portland Reporter: Jehan <jehan>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: xdg-email: reset the IFS before interpreting a shell command.

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.