[Portland] xdg-open file:// urls and escaped characters

Henning Garus henning.garus at googlemail.com
Mon Sep 27 09:40:50 PDT 2010


With the current cvs version of xdg-open (xdg-open.in 1.38) opening
file:// urls containing escaped characters such as %20 is broken. I
presume revision 1.33 was meant to address this issue, but did not work,
since your average shell does not expand \xNN. However printf does.

Unless there was any other reason to revert the changes made in revision
1.33 the following patch should provide decoding for file urls.


--- xdg-open.in.orig  2010-09-27 18:24:31.266941328 +0200
+++ xdg-open.in 2010-09-27 18:27:42.436941326 +0200
@@ -115,10 +115,13 @@
     if (echo "$1" | grep -q '^file://' ||
         ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
 
-        local file=$(echo "$1" | sed 's%^file://%%')
+        local file="$1"
 
         # Decode URLs
-        # TODO
+        if echo "$file" | grep -q '^file:///'; then
+            file=${file#file://}
+            file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1 at g')")"
+        fi
 
         check_input_file "$file"



More information about the Portland mailing list