[hackers] diri: new tip (= 42)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Thu, 01 Feb 2007 15:00:02 +0100

changeset: 42:3b628204d1b1
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Thu Feb 01 14:50:13 2007 +0100
files: edit.rc remove.rc save.rc show.rc
description:
continued with uncluttering the code

diff -r c0b771171f58 -r 3b628204d1b1 edit.rc
--- a/edit.rc Thu Feb 01 14:42:33 2007 +0100
+++ b/edit.rc Thu Feb 01 14:50:13 2007 +0100
@@ -8,6 +8,7 @@ if(! test $PATH_INFO || echo $PATH_INFO
         echo
         exit 0
 }
+PATH_INFO=`{cleanname $PATH_INFO}
 if(test -d $DIRIDIR/$PATH_INFO) {
         echo Location: $ADDRESS/$SHOW/$PATH_INFO
         echo
@@ -50,7 +51,7 @@ END
         echo $PATH_INFO
 cat <<END
 </h1>
- <form action="$ADDRESS/$SAVE$PATH_INFO" method="post">
+ <form action="$ADDRESS/$SAVE/$PATH_INFO" method="post">
                                 <textarea name='text' id='text' cols='80' rows='43'>
 END
 if(test -f $DIRIDIR/$PATH_INFO.diri) {
diff -r c0b771171f58 -r 3b628204d1b1 remove.rc
--- a/remove.rc Thu Feb 01 14:42:33 2007 +0100
+++ b/remove.rc Thu Feb 01 14:50:13 2007 +0100
@@ -1,5 +1,11 @@
 #!/usr/local/plan9/bin/rc
 . /var/www/dirirc
+
+fn escape {
+ echo Location: $ADDRESS/$SHOW/$PATH_INFO
+ echo
+ exit 0
+}
 
 if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$'
         || echo $PATH_INFO | grep -v -s '[a-zA-Z0-9]')
@@ -8,16 +14,9 @@ if(! test $PATH_INFO || echo $PATH_INFO
         echo
         exit 0
 }
-
-fn escape {
- echo Location: $ADDRESS/$SHOW/$PATH_INFO
- echo
- exit 0
-}
-
+PATH_INFO=`{cleanname $PATH_INFO}
 for(i in `{sed 's/\&/ /g'})
         eval $i
-
 if(test $password) {
         password=`{echo -n $password | $URLDECODE | $HASHCMD}
         if(! ~ $password $HASHPASSWD || test ! $text)
@@ -66,7 +65,7 @@ END
         echo $PATH_INFO
 cat <<END
 </h1>
- <form action="$ADDRESS/$REMOVE$PATH_INFO" method="post">
+ <form action="$ADDRESS/$REMOVE/$PATH_INFO" method="post">
                                 <p style='color: #f00;'>Please confirm removing '$PATH_INFO' through entering the password.</p>
                                 <p align="right">
                                         <b>Password:</b> <input type='password' name='password' size='20'/>
diff -r c0b771171f58 -r 3b628204d1b1 save.rc
--- a/save.rc Thu Feb 01 14:42:33 2007 +0100
+++ b/save.rc Thu Feb 01 14:50:13 2007 +0100
@@ -1,5 +1,11 @@
 #!/usr/local/plan9/bin/rc
 . /var/www/dirirc
+
+fn escape {
+ echo Location: $ADDRESS/$SHOW/$PATH_INFO
+ echo
+ exit 0
+}
 
 if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$'
         || echo $PATH_INFO | grep -v -s '[a-zA-Z0-9]')
@@ -8,27 +14,17 @@ if(! test $PATH_INFO || echo $PATH_INFO
         echo
         exit 0
 }
-
-fn escape {
- echo Location: $ADDRESS/$SHOW/$PATH_INFO
- echo
- exit 0
-}
-
+PATH_INFO=`{cleanname $PATH_INFO}
 if(test -d $DIRIDIR/$PATH_INFO)
         escape
-
 for(i in `{sed 's/\&/ /g'})
         eval $i
-
 if(test $password)
         password=`{echo -n $password | $URLDECODE | $HASHCMD}
 if not
         escape
-
 if(! ~ $password $HASHPASSWD || ! test $text)
         escape
-
 dirs=`{basename -d $PATH_INFO}
 if(test $dirs)
         /bin/mkdir -p $DIRIDIR/$dirs
diff -r c0b771171f58 -r 3b628204d1b1 show.rc
--- a/show.rc Thu Feb 01 14:42:33 2007 +0100
+++ b/show.rc Thu Feb 01 14:50:13 2007 +0100
@@ -35,16 +35,16 @@ if(test $PATH_INFO && echo $PATH_INFO |
         echo
         exit 0
 }
-
 if(! test $PATH_INFO)
         PATH_INFO=''
+PATH_INFO=`{cleanname $PATH_INFO}
 
 if(test -d $DIRIDIR/$PATH_INFO) {
         file=`{find $DIRIDIR/$PATH_INFO -type f | grep '/[a-zA-Z0-9_]+$' | sort | sed 1q}
         if(test $file && test -f $file) {
                 file=`{cleanname $file}
                 arg='s,'^$DIRIDIR^'/,,'
- PATH_INFO=/`{echo $file | sed $arg}
+ PATH_INFO=`{echo $file | sed $arg}
         }
 }
 tmp=$ifs
@@ -96,8 +96,8 @@ Content-Type: text/html
                 </div>
                 <div id="ctrlmenu">
                         <ul>
- <li>edit</li>
- <li>remove</li>
+ <li>edit</li>
+ <li>remove</li>
                         </ul>
                 </div>
                 <div style='clear: both; padding: 0px;'></div>
Received on Thu Feb 01 2007 - 15:00:03 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:49 UTC