[Portland-bugs] [Bug 81386] New: xdg-utils fails if user sets a custom IFS environment variable

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Jul 15 07:48:32 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=81386

          Priority: medium
            Bug ID: 81386
          Assignee: portland-bugs at lists.freedesktop.org
           Summary: xdg-utils fails if user sets a custom IFS environment
                    variable
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: jehan at zemarmot.net
          Hardware: Other
            Status: NEW
           Version: unspecified
         Component: xdg-utils
           Product: Portland

Created attachment 102859
  --> https://bugs.freedesktop.org/attachment.cgi?id=102859&action=edit
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 at 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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/portland-bugs/attachments/20140715/b59c94ef/attachment.html>


More information about the Portland-bugs mailing list