2012-01-06 16:03, Cyril Soldani skrev:
> On Fri, 06 Jan 2012 15:18:13 +0100
> Per Olofsson <pe...@dsv.su.se> wrote:
>> Hmm, perhaps it is better to use awk here. How about this:
>>
>> arguments_exec=`echo $arguments | awk -v url="$1" \
>>      '{gsub(/%[fFuU]/, url); print}'`
> 
> I think the problem stays the same, as GNU awk also replaces ampersands
> by the matched pattern (and \1 to \9 are also replaced by matched
> groups with awk).

Ah, right. I missed that. mawk does the same thing BTW.

> I did a quick research myself revealing that it is a somehow frequent
> problem, but I found no solution other than escaping URL first.

I think we could do it using perl without escaping, but upstream doesn't
accept perl as a dependency.

> Apparently, the only two characters to be escaped are & and \ (both for
> sed and for awk).

'\' is not allowed unescaped in URI's though. But it is probably safer
to escape it as well.

I guess escaping is the way to go then. So how about this clever pattern
which escapes both characters:

local escaped=$(echo "$1" | sed -e 's/[&\\]/\\&/g')

-- 
Pelle



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to