Bug 66605 - xdg-desktop-menu does not support filenames with spaces
Summary: xdg-desktop-menu does not support filenames with spaces
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: 1.1.0 rc1
Hardware: All All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords: patch
: 69339 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-05 00:39 UTC by Matt Giuca
Modified: 2015-08-26 05:41 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Matt Giuca 2013-07-05 00:39:59 UTC
Steps to reproduce:

1. Create a .desktop file with a vendor prefix and a space in the name. e.g., "foo-bar baz.desktop".
2. Run: xdg-desktop-menu install --mode user "foo-bar baz.desktop"

Expected result: The file is copied to "~/.local/share/applications/foo-bar baz.desktop".

Actual result:
xdg-desktop-menu: filename 'baz.desktop' does not have a proper vendor prefix
A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
with a dash ("-"). An example filename is 'example-baz.desktop'
Use --novendor to override or 'xdg-desktop-menu --manual' for additional info.

This is because it thinks I am passing two separate filenames ("foo-bar" and "baz.desktop") even though I correctly used quotes on the command line. This is caused by line 998 of the script, which concatenates all arguments ending in .desktop onto $desktop_files, separating each argument with a space. After that point, it is impossible to tell which spaces separate arguments and which are part of the filename.

(Note that if all of the space-separated parts of the filename contain a "-", you don't see the above error, it just fails silently because it can't find the files it is trying to copy.)
Comment 1 Rex Dieter 2013-09-16 12:59:33 UTC
Fixing this could get a little ugly... in the meantime I would simply and strongly recommend avoiding the use of .desktop filenames with spaces (converting " " to "_" or something...)
Comment 2 Rodrigo Silva 2015-04-04 07:12:08 UTC
This affects more than just installing `.desktop` files. It also affects uninstalling *any* .directory file, with spaces or not, if `XDG_CONFIG_HOME/menus/applications-merged` contains a `.menu` file with spaces.

In this case, a simple `xdg-desktop-menu uninstall vendor-foo.directory vendor-bar.desktop` *freezes*. Notice there's no spaces in those names!

This was reported in Ubuntu as https://bugs.launchpad.net/xdg-utils/+bug/1432932 , and it contains a working patch that does not seem ugly: it simply quotes the vars as they should be.

"avoiding the use of .desktop filenames with spaces" is not always an option:  wine creates such files, and they do so by design (its .menu files are named after their windows `.lnk` counterparts).

So if a user has wine-installed games, no other software will be able to uninstall its own .directory files!

Any chance this patch could be merged?
Comment 3 Rodrigo Silva 2015-04-04 08:49:15 UTC
By the way, I can see one of such unquoted vars was already fixed in git repository in commit http://cgit.freedesktop.org/xdg/xdg-utils/commit/?id=c96d7b00aca3da1b608fde5827d7fea8785b3cd3 , which is great... thanks Rex Dieter!

This commit fixes the particular case of wine .menu files, which do not contain the 'generated and managed' "tag". But for a more general solution, there is another occurrence of the same var unquoted a few lines below at http://cgit.freedesktop.org/xdg/xdg-utils/tree/scripts/xdg-desktop-menu.in#n306 and a few lines above at #288.

Care to fix those too?
Thanks!
Comment 5 Rodrigo Silva 2015-08-26 05:41:16 UTC
*** Bug 69339 has been marked as a duplicate of this bug. ***


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.