Bug 45859 - xdg-open fails to open a url in a "generic" environment
Summary: xdg-open fails to open a url in a "generic" environment
Status: RESOLVED FIXED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: 1.1.0
Hardware: Other All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords: patch
: 44164 49970 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-09 14:25 UTC by Göran Uddeborg
Modified: 2014-12-15 22:38 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Complete log generated with bash -xv xdg-open URL (24.71 KB, text/plain)
2012-06-16 05:23 UTC, Mateusz Loskot
Details
Solution by David Costa in form of patch (399 bytes, patch)
2012-08-09 09:51 UTC, Sergey Shepelev
Details | Splinter Review

Description Göran Uddeborg 2012-02-09 14:25:56 UTC
When using xdg-open on a typical URL in an environment which is considered "generic", my browser comes up with to tabs.  One shows www.http.com and the other tries to open the real URL path as a file, which fails of course.

The reason for this seems to be an improper use of IFS in the script.  The different browsers to try are separated by colons, and to easily loop over them, IFS is set to colon.  But that will also affect the colon which is typically part of the URL, and split it into two separate arguments to the browser.  See the output from running xdg-open with "bash -xv" at the end.

This is with xdg-utils-1.1.0-0.10.20111207.fc16.noarch on a Fedora system.

This output comes from running open_generic, starting at line 612 in my copy of xdg-open.  Note that x-www-browser and firefox are called with two separate arguments, rather than a single URL.

+ IFS=:
+ for browser in '$BROWSER'
+ '[' xx-www-browser '!=' x ']'
printf "$browser" "$1" 2>/dev/null
++ printf x-www-browser http://portland.freedesktop.org/
+ browser_with_arg=x-www-browser
+ '[' 0 -ne 0 ']'
+ '[' xx-www-browser = xx-www-browser ']'
+ eval '$browser $1 > /dev/null 2> /dev/null'
$browser $1 > /dev/null 2> /dev/null
++ x-www-browser http //portland.freedesktop.org/
+ '[' 127 -eq 0 ']'
+ for browser in '$BROWSER'
+ '[' xfirefox '!=' x ']'
printf "$browser" "$1" 2>/dev/null
++ printf firefox http://portland.freedesktop.org/
+ browser_with_arg=firefox
+ '[' 0 -ne 0 ']'
+ '[' xfirefox = xfirefox ']'
+ eval '$browser $1 > /dev/null 2> /dev/null'
$browser $1 > /dev/null 2> /dev/null
++ firefox http //portland.freedesktop.org/
+ '[' 0 -eq 0 ']'
+ exit_success
+ '[' 0 -gt 0 ']'
+ exit 0
Comment 1 Mateusz Loskot 2012-06-16 05:23:22 UTC
Created attachment 63106 [details]
Complete log generated with bash -xv xdg-open URL

I can confirm this bug on Arch Linux (up-to-date).

Here is relevant part of my output generated for:
bash -xv xdg-open "http://www.gnu.org"

+ IFS=:
+ for browser in '$BROWSER'
+ '[' xx-www-browser '!=' x ']'
printf "$browser" "$1" 2>/dev/null
++ printf x-www-browser http://www.gnu.org
+ browser_with_arg=x-www-browser
+ '[' 0 -ne 0 ']'
+ '[' xx-www-browser = xx-www-browser ']'
+ eval '$browser $1 > /dev/null 2> /dev/null'
$browser $1 > /dev/null 2> /dev/null
++ x-www-browser http //www.gnu.org
+ '[' 127 -eq 0 ']'
+ for browser in '$BROWSER'
+ '[' xfirefox '!=' x ']'
printf "$browser" "$1" 2>/dev/null
++ printf firefox http://www.gnu.org
+ browser_with_arg=firefox
+ '[' 0 -ne 0 ']'
+ '[' xfirefox = xfirefox ']'
+ eval '$browser $1 > /dev/null 2> /dev/null'
$browser $1 > /dev/null 2> /dev/null
++ firefox http //www.gnu.org


Notice the URL split into "http" and "//www.gnu.org" parts.

Complete log attached.


My environment:
mloskot ~ $ uname -a
Linux dog 3.4.2-2-ARCH #1 SMP PREEMPT Mon Jun 11 22:27:17 CEST 2012 x86_64 GNU/Linux

mloskot ~ $ firefox -v
Mozilla Firefox 13.0.1

mloskot ~ $ xdg-open --version
xdg-open 1.1.0 rc1
Comment 2 David Costa 2012-06-22 13:53:04 UTC
The eval parameter on line 659 is not quoted. 

The original line is:
eval '$browser $1'$xdg_redirect_output;

while it should be:
eval '$browser "$1"'$xdg_redirect_output;

Tested and working on xdg-open 1.1.0 rc1 on Arch Linux (up to date) with Mozilla Firefox 13.0.1
Comment 3 Mateusz Loskot 2012-06-24 07:15:17 UTC
(In reply to comment #2)
> while it should be:
> eval '$browser "$1"'$xdg_redirect_output;

I also can confirm it fixes the problem.
Comment 4 Sergey Shepelev 2012-08-09 09:51:13 UTC
Created attachment 65338 [details] [review]
Solution by David Costa in form of patch

I also confirm that bug exists in xdg-open 1.1.0 rc1
and that quoting $1 on line 659 fixes it. Please, apply the patch.

Thanks David Costa.
Comment 6 Göran Uddeborg 2013-01-07 14:21:01 UTC
*** Bug 44164 has been marked as a duplicate of this bug. ***
Comment 7 Rex Dieter 2014-12-15 22:38:05 UTC
*** Bug 49970 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.