[hackers] [diri] applied some fixes proposed by bogon

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Mon Feb 12 09:29:20 2007

changeset: 59:000147f97671
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Mon Feb 12 09:27:53 2007 +0100
summary: applied some fixes proposed by bogon

diff -r a64f868a5d37 -r 000147f97671 remove.rc
--- a/remove.rc Wed Feb 07 13:45:36 2007 +0100
+++ b/remove.rc Mon Feb 12 09:27:53 2007 +0100
@@ -1,33 +1,37 @@
 #!/usr/local/plan9/bin/rc
 . /var/www/dirirc
 
-fn escape {
- echo Location: $ADDRESS/$SHOW/$PATH_INFO
+fn redirect {
+ echo Location: $ADDRESS/$"*
         echo
         exit 0
 }
 
+fn setvars {
+ while(input=`{read}) {
+ for(var) {
+ if(echo $"input | grep -s '^'$"var'=') {
+ value=`{echo $"input | sed 's/^'$"var'=//'}
+ eval $"var'=$"value'
+ }
+ }
+ }
+}
+
 if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$'
         || echo $PATH_INFO | grep -v -s '[a-zA-Z0-9]')
-{
- echo Location: $ADDRESS/$SHOW
- echo
- exit 0
-}
+ redirect $SHOW
 PATH_INFO=`{cleanname $PATH_INFO | sed 's/^.//'}
-for(i in `{sed 's/\&/ /g'})
- eval $i
+setvars password
 if(test $password) {
         password=`{echo -n $password | $URLDECODE | $HASHCMD}
         if(! ~ $password $HASHPASSWD || test ! $text)
- escape
+ redirect $SHOW/$PATH_INFO
         if(test -e $DIRIDIR/$PATH_INFO) {
                 /bin/rm -rf $DIRIDIR/$PATH_INFO.diri
                 /bin/rm -rf $DIRIDIR/$PATH_INFO
         }
- echo Location: $ADDRESS/$SHOW
- echo
- exit 0
+ redirect $SHOW
 }
 title=`{basename $PATH_INFO | sed 's/^[0-9]+_//; s/_/ /g'}
 cat <<END
diff -r a64f868a5d37 -r 000147f97671 save.rc
--- a/save.rc Wed Feb 07 13:45:36 2007 +0100
+++ b/save.rc Mon Feb 12 09:27:53 2007 +0100
@@ -1,30 +1,36 @@
 #!/usr/local/plan9/bin/rc
 . /var/www/dirirc
 
-fn escape {
- echo Location: $ADDRESS/$SHOW/$PATH_INFO
+fn redirect {
+ echo Location: $ADDRESS/$"*
         echo
         exit 0
 }
 
+fn setvars {
+ while(input=`{read}) {
+ for(var) {
+ if(echo $"input | grep -s '^'$"var'=') {
+ value=`{echo $"input | sed 's/^'$"var'=//'}
+ eval $"var'=$"value'
+ }
+ }
+ }
+}
+
 if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$'
         || echo $PATH_INFO | grep -v -s '[a-zA-Z0-9]')
-{
- echo Location: $ADDRESS/$SHOW
- echo
- exit 0
-}
+ redirect $SHOW
 PATH_INFO=`{cleanname $PATH_INFO | sed 's/^.//'}
 if(test -d $DIRIDIR/$PATH_INFO)
         escape
-for(i in `{sed 's/\&/ /g'})
- eval $i
+setvars password text
 if(test $password)
         password=`{echo -n $password | $URLDECODE | $HASHCMD}
 if not
- escape
+ redirect $SHOW/$PATH_INFO
 if(! ~ $password $HASHPASSWD || ! test $text)
- escape
+ redirect $SHOW/$PATH_INFO
 dirs=`{basename -d $PATH_INFO}
 if(test $dirs)
         /bin/mkdir -p $DIRIDIR/$dirs
@@ -33,5 +39,4 @@ echo $text | $URLDECODE > $DIRIDIR/$PATH
 echo $text | $URLDECODE > $DIRIDIR/$PATH_INFO.diri
 cp $DIRIDIR/$PATH_INFO.diri $DIRIDIR/$PATH_INFO.`{date -n}
 $WIKIFMT < $DIRIDIR/$PATH_INFO.diri > $DIRIDIR/$PATH_INFO
-echo Location: $ADDRESS/$SHOW/$PATH_INFO
-echo
+redirect $SHOW/$PATH_INFO
Received on Mon Feb 12 2007 - 09:29:20 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:12 UTC