Bug 101039 - xdg-mime does not handle whitespace in .desktop file names correctly
Summary: xdg-mime does not handle whitespace in .desktop file names correctly
Status: NEW
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-14 19:33 UTC by Vladimir Panteleev
Modified: 2017-07-07 16:23 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Panteleev 2017-05-14 19:33:05 UTC
On my system, running:

$ xdg-open http://google.com

Prints this to stderr:

/usr/sbin/xdg-mime: line 323: [: too many arguments
/usr/sbin/xdg-mime: line 325: [: too many arguments

xdg-mime at line 323 looks like this:

            if [ -r $dir/applications/$vendor/$app ]; then
                file_path=$dir/applications/$vendor/$app
            elif [ -r $dir/applnk/$vendor/$app ]; then
                file_path=$dir/applnk/$vendor/$app
            fi

It looks like xdg-mime does not properly quote variables before expansion, which makes them subject to globbing and word splitting.

The particular file that causes xdg-mime to misbehave is:

/home/vladimir/.local/share/applications/userapp-Firefox Developer Edition-ZN8AEY.desktop

I'm not sure what created it, but it does have spaces in the file name.

Regardless of whether spaces are allowed in such file names, not quoting variables that are not intended to be expanded is a bug.

I strongly recommend linting shell scripts with ShellCheck (http://www.shellcheck.net/) to prevent bugs like this one.
Comment 1 Vladimir Panteleev 2017-07-07 16:23:16 UTC
This is a regression.

Introduced in 7836138fe83d7ac94a711d51038ebf456069e161


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.