Bug 44046

Summary: xdg-open with x-scheme-handler replaces & in URLs with %U
Product: Portland Reporter: Stephan Sokolow <freedesktop.zen.ssokolow>
Component: xdg-utilsAssignee: Portland Bugs <portland-bugs>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium CC: freedesktop
Version: TP   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Stephan Sokolow 2011-12-22 03:02:30 UTC
As of this moment, I'm running the current git HEAD (b961235b197647d6649ef3d48d7cc2cecafe3d47) in order to get proper URI handling under LXDE. (Not that it's detected as such. See bug #36905)

With this version, ampersands in the the query string of an HTTP URL are converted to %U, breaking the URL in the process.

Here's an example which will demonstrate the issue when run:

xdg-open http://www.youtube.com/watch?feature=relmfu&v=zlfKdbWwruY

I've manually reversed the order of the parameters because ordinary YouTube URLs work (Apparently, if you pass something too long for the "v" parameter, YouTube will truncate it and try again) and the original case I encountered this bug in was clicking the link in my Bugzilla confirmation e-mail inside Thunderbird.
Comment 1 Adam Jacob Muller 2011-12-26 13:38:52 UTC
This is due to the following line in xdg-open:

arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$1"'"*g'`"

In sed parlance the "&" is special, from the sed man page: "The replacement may contain the special character & to refer to that portion of the pattern space which matched"

So any & in the URL will be replaced with the arguments.

The simple fix for this is to escape & in the input string, though a more robust fix is probably in order (not using PCRE perhaps) the following patch fixes the problem.


argone=`echo $1|sed 's/&/\\\\&/g'`
arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$argone"'"*g'`"
Comment 2 Adam Jacob Muller 2011-12-26 13:39:57 UTC
> (not using PCRE perhaps)

s/PC//
Comment 3 GitLab Migration User 2019-02-16 13:34:43 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/55.

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.