root/10kz/shell/parse-decoded-params.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:keywords set to Id
Line 
1 #!/bin/sh
2 # $Id$
3
4 if [ -z "$QUERY_STRING" ]
5 then
6         qs=$1
7 else
8         echo Content-type: text/plain
9         echo
10         # the fizmezwebserver doesn't seem to need an extra echo here, even tho it should...?
11         qs="foo?$QUERY_STRING"
12 fi
13
14 is_qs=`echo "$qs" | grep "\?" > /dev/null`
15 if [ $? -ne 0 ]
16 then
17         echo "no ? found in qs\; bailing"
18         exit 1
19 fi
20
21 s=$qs
22
23 params=`echo $s | sed "s/^.*\?//"`
24 for p in $params
25 do
26         tokens=`echo $p | sed "s/\+/__SPACE__/g" | sed "s/%26/__AMP__/g" | sed "s/%\([0-9A-F][0-9A-F]\)/ HEX:\1 /g"`
27
28         full=""
29
30         for t in $tokens
31         do
32                 echo $t | grep -q HEX:
33                 if [ $? = 0 ]
34                 then
35                         t=`echo $t | sed s/HEX://`
36                         tok=`printf "%d" 0x$t | awk '{printf("%c", $1)}'`
37                         full="$full$tok"
38                 else
39                         tok=`echo $t | sed "s/__SPACE__/ /g"`
40                         full="$full$tok"
41                 fi
42                 done
43                 echo
44 done
45
46 vars="key_id passphrase plaintext recipients"
47 echo
48 failures=""
49 for var in $vars
50 do
51         #echo looking for $var in $full
52         echo "$full" | grep -q "$var"
53         if [ $? -eq 0 ]
54         then
55                 val=`echo "$full" | sed "s/^.*$var=\([^&]*\).*/\1/" | sed "s/__AMP__/\&/g"`
56                 echo $val
57
58                 # set each of the values in a variable so we can access it from the main program:
59                 export `echo $var`="$val"
60         else
61                 failures="$failures No $var found."
62         fi
63 done
64
65 if [ -n "$failures" ]
66 then
67         echo ERRORS: $failures
68         exit 1
69 fi
70
71 exit 0
72
Note: See TracBrowser for help on using the browser.