Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 623856 - x11-misc/xdg-utils-1.1.2 : xdg-mime does not handle paths correctly ( line 323: [: too many arguments )
Summary: x11-misc/xdg-utils-1.1.2 : xdg-mime does not handle paths correctly ( line 32...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Freedesktop bugs
URL: https://gitlab.freedesktop.org/xdg/xd...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-05 00:04 UTC by Kent Fredric (IRC: kent\n)
Modified: 2019-05-15 01:04 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
xdg-utils-fix-unquoted-paths.patch (xdg-utils-fix-unquoted-paths.patch,733 bytes, patch)
2019-05-15 01:04 UTC, Peter Levine
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Fredric (IRC: kent\n) gentoo-dev 2017-07-05 00:04:11 UTC
I started noticing this error in my terminal from quassel-client:



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



The relevant lines are the obviously dangerous: 

  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

echoing the value of "vendor" and "app" indicates they *both* contain spaces:

  echo "vendor: '${vendor}'" >&2
  echo "app: '${app}'" >&2

  vendor: 'userapp-Pale Moon'
  app: 'Pale Moon-FGUVNY.desktop'

Surprise, this looks a lot like bug #540628


----

x11-misc/xdg-utils-1.1.2::gentoo was built with the following:
USE="perl -doc" ABI_X86="(64)"

Timestamp of repository gentoo: Wed, 21 Jun 2017 15:30:01 +0000

Last change to xdg-utils-1.1.2:

commit ada30fbff65f62fc734c992a3961aac6873ba69e
Date:   2017-05-09 13:12:53 +1200
Comment 1 Mike Gilbert gentoo-dev 2017-07-05 02:11:07 UTC
According to the Desktop Entry Specification, spaces are not valid in .desktop file names.

https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html

"The valid characters (aside '.') are [A-Z][a-z][0-9] along with dash ('-') and underscore ('_'). Components may not begin with a digit."

That said, this still seems like sloppy shell coding.
Comment 2 Pacho Ramos gentoo-dev 2017-12-16 13:02:20 UTC
Please report this to upstream and post the link here to let us track the issue:
https://bugs.freedesktop.org/enter_bug.cgi?product=Portland&component=xdg-utils
Comment 3 Johannes Huber gentoo-dev 2018-06-13 17:38:37 UTC
Is this still valid with 1.1.3?
Comment 4 Kent Fredric (IRC: kent\n) gentoo-dev 2018-06-14 19:11:15 UTC
(In reply to Johannes Huber from comment #3)
> Is this still valid with 1.1.3?

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


 $ xdg-mime --version
xdg-mime 1.1.3


Yes.
Comment 5 Peter Levine 2019-05-15 01:04:08 UTC
Created attachment 576710 [details, diff]
xdg-utils-fix-unquoted-paths.patch

Could someone who can reproduce the issue please test out this patch and confirm it fixes the problem?