Hi, 2012-01-06 12:39, Cyril Soldani skrev: > Investigating a bit, I found the problem to be at line 552 of xdg-open: > arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$1"'"*g'`" > In our case, $arguments contains '%u'. The problem is with the sed > expression, which uses $1 (our URL) without escaping ampersands in it. > In the replacement part of a sed expression, an unescaped & stands for > the portion of the pattern that matched. In our case, every & in the URL > is thus replaced by a '%u'.
Indeed. Thanks for spotting this! > As a quick fix, I modified mine as follows: > escaped="`echo $1 | sed -e 's/&/\\\&/g'`" > arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$escaped"'"*g'`" > > This allows me to open HTTP URLs with ampersands as expected. However, I > give it more as an illustration of the problem than as a serious fix > proposal: > - It may not be the most elegant way to fix it. > - It may be necessary also in other places. > - It is necessary also for other characters. E.g. > xdg-open "https://www.google.com/search?q=grail\1" > fails with the message > sed: -e expression #1, char 53: invalid reference \1 on `s' command's RHS > instead of opening the URL. Hmm, perhaps it is better to use awk here. How about this: arguments_exec=`echo $arguments | awk -v url="$1" \ '{gsub(/%[fFuU]/, url); print}'` (the most elegant way to fix it though would be to rewrite xdg-utils in some other language than shell :-) ) -- Pelle -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org