Bug 44046 - xdg-open with x-scheme-handler replaces & in URLs with %U
Summary: xdg-open with x-scheme-handler replaces & in URLs with %U
Status: RESOLVED MOVED
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: TP
Hardware: Other All
: medium normal
Assignee: Portland Bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-22 03:02 UTC by Stephan Sokolow
Modified: 2019-02-16 13:34 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

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.