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
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Portland Bugs
QA Contact:
Depends on:
Reported: 2017-05-14 19:33 UTC by Vladimir Panteleev
Modified: 2019-02-16 13:38 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


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
            elif [ -r $dir/applnk/$vendor/$app ]; then

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
Comment 2 GitLab Migration User 2019-02-16 13:38:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/107.

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.