On Sun, 08 Jan 2012 18:57:48 +0100 Per Olofsson <pe...@dsv.su.se> wrote: > > 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 agree. Although my example was a bit contrived, it seems to work as intended when passed directly to iceweasel so 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') Nice one. Does the job, clear and short. P.S. : I checked the remainder of xdg-open script if there were other occurrences of sed with $1 in the replacement string, and this was the only one. Regards, -- "As we enjoy great Advantages from the Inventions of others, we should be glad of an Opportunity to serve others by any Invention of ours; and this we should do freely and generously." Benjamin Franklin Cyril Soldani <devmusi...@legiasoft.com> http://devmusings.legiasoft.com/
signature.asc
Description: PGP signature