Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 623856

Summary: x11-misc/xdg-utils-1.1.2 : xdg-mime does not handle paths correctly ( line 323: [: too many arguments )
Product: Gentoo Linux Reporter: Kent Fredric (IRC: kent\n) (RETIRED) <kentnl>
Component: Current packagesAssignee: Freedesktop bugs <freedesktop-bugs>
Status: CONFIRMED ---    
Severity: normal CC: annulen, floppym, johu, nbowler, plevine457, tsmksubc
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/107
See Also: https://bugs.gentoo.org/show_bug.cgi?id=540628
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: xdg-utils-fix-unquoted-paths.patch

Description Kent Fredric (IRC: kent\n) (RETIRED) 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 (RETIRED) gentoo-dev 2018-06-13 17:38:37 UTC
Is this still valid with 1.1.3?
Comment 4 Kent Fredric (IRC: kent\n) (RETIRED) 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?
Comment 6 Konstantin Tokarev 2024-01-16 15:20:21 UTC
Tried your patch, works fine here. Thanks!