Bug 15661 - xdg-open breaks on spaces in paths when using generic open method
Summary: xdg-open breaks on spaces in paths when using generic open method
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: low normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-22 15:39 UTC by John Carlyle-Clarke
Modified: 2009-02-21 15:48 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description John Carlyle-Clarke 2008-04-22 15:39:32 UTC
xdg-utils 1.0.1-2 on Ubuntu Gutsy 7.10

xdg-open tries to detect the desktop environment and falls back to a generic method using run-mailcap.  There is a bug in this function open_generic() that means if the path contains a space, the method fails.

e.g.

johncc@liberator:~$ xdg-open Fire\ stockists.txt 
local: 438: stockists.txt: bad variable name
Warning: unknown mime-type for "Fire" -- using "application/*"
Error: no such file "Fire"

To provoke this bug you need to not be running GNOME, KDE or XFCE.  In GNOME you can fake this by doing:-

unset GNOME_DESKTOP_SESSION_ID
touch file\ with\ spaces.txt
xdg-open file\ with\ spaces.txt 

The problem is just missing quotes.  A simple patch fixes it for me.

373c373
< 	local file="$(echo "$1" | sed 's%^file://%%')"
---
> 	local file=$(echo "$1" | sed 's%^file://%%')
Comment 1 Greg Grossmeier 2008-04-22 16:29:23 UTC
Confirmed this behavior in Hardy (xdg-utils 1.0.2-2) with the following:

greg@alexandria:~$echo $GNOME_DESKTOP_SESSION_ID
Default
greg@alexandria:~$unset GNOME_DESKTOP_SESSION_ID
greg@alexandria:~$echo $GNOME_DESKTOP_SESSION_ID

greg@alexandria:~$touch file\ with\ spaces.txt
greg@alexandria:~$xdg-open file\ with\ spaces.txt
local: 438: spaces.txt: bad variable name
Warning: unknown mime-type for "file" -- using "application/*"
Error: no such file "file"
greg@alexandria:~$touch file%20with%20a\ space.txt
greg@alexandria:~$ls | grep file
file%20with%20a space.txt
file with spaces.txt
greg@alexandria:~$xdg-open file%20with%20a\ space.txt
local: 438: space.txt: bad variable name
Warning: unknown mime-type for "file%20with%20a" -- using "application/*"
Error: no such file "file%20with%20a"

After an "export GNOME_DESKTOP_SESSION_ID=Default" the above xdg-open commands work as expected.
Comment 2 James Westby 2009-02-21 15:48:00 UTC
Hi,

I have tested this and it is fixed in 1.0.2

Thanks,

James


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.