root/10kz/shell/url-decode.jm3

Revision 43, 1.2 kB (checked in by jm3, 2 years ago)
  • set Id property on all text-based files
  • correctly handling the "no keys found" case with link to GPG help page (just a stub at this point)
  • Property svn:executable set to *
  • Property svn:keywords set to Id
Line 
1 #!/bin/sh
2
3 echo Content-type: text/html
4 echo
5
6 # test urls:
7 s="foo.com?paramone=valueone+value1.1"
8 s="foo.com?paramone=valueone+value1.1&p2=val%20thingy%20more%20more%2Fmore"
9 s="feedmelinks.com/login?bounceToPage=%2Fcategorize%3F%26loggedIn%3Dwasnt%26from%3Dtoolbar%26op%3Dsubmit%26name%3DFlickr%253A%2520Photos%2520tagged%2520with%2520jm3%26url%3Dhttp%253A%2F%2Fwww.flickr.com%2Fphotos%2Ftags%2Fjm3%2Finteresting%2F%26ref%3Dhttp%253A%2F%2Fwww.flickr.com%2Fphotos%2Ftags%2Fjm3%2F%26version%3D0.7"
10 s="google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&ltmpl=wsad&ltmplcache=2"
11
12 if [ -z "$QUERY_STRING" ]
13 then
14         echo "<h1>no query string found; exiting</h1>"
15         exit 1
16 fi
17
18 s=$QUERY_STRING
19
20 params=`echo $s | sed "s/^.*\?//" | sed "s/&/ /g"`
21 for p in $params
22 do
23         echo $p
24         tokens=`echo $p | sed "s/\+/__SPACE__/g" | sed "s/%\([0-9A-F][0-9A-F]\)/ HEX:\1 /g"`
25
26         for t in $tokens
27         do
28                 echo $t | grep -q HEX:
29                 if [ $? = 0 ]
30                 then
31                         t=`echo $t | sed s/HEX://`
32                         echo `printf "%d" 0x$t` | awk '{printf("%c", $1)}'
33                 else
34                         echo -n `echo $t | sed "s/__SPACE__/ /g"`
35                 fi
36                 done
37                 echo
38                 echo
39
40 done
41
42 exit 0
43
Note: See TracBrowser for help on using the browser.