Permalink
Browse files

TBS can now handle urlencoded urls requested by browser, e.g. for res…

…ource names with spaces
  • Loading branch information...
1 parent 202bce8 commit f3b2dbf494c37e1ffc9928a8bf28a7c076a68487 @sayanriju committed Oct 25, 2010
Showing with 23 additions and 2 deletions.
  1. +3 −0 README.md
  2. +1 −1 uninstaller
  3. +19 −1 usr/bin/tinybashserver
View
@@ -49,6 +49,9 @@ After downloading, the contained files are to be placed under / maintaining the
executable permissions.
Right now, the default installation options are rather hard coded.
+P.S: Now there's a simple installer script to automate the above process. An uninstaller script is also added
+to do just the opposite.
+
####To start TBS:
View
2 uninstaller 100644 → 100755
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
if [ $UID -ne 0 ];then
- echo "This installer script must be run as root"
+ echo "This uninstaller script must be run as root"
echo "Aborting."
exit 1
fi
View
@@ -96,6 +96,24 @@ EOF
parseHttpRequest
parseRequestUrl
createVariableString
+## Handle urlencoded url
+urldecode() {
+ arg="$1"
+ i="0"
+ while [ "$i" -lt ${#arg} ]; do
+ c0=${arg:$i:1}
+ if [ "x$c0" = "x%" ]; then
+ c1=${arg:$((i+1)):1}
+ c2=${arg:$((i+2)):1}
+ printf "\x$c1$c2"
+ i=$((i+3))
+ else
+ echo -n "$c0"
+ i=$((i+1))
+ fi
+ done
+}
+url=`urldecode "$url"`
filename="$DOCROOT$url"
if [ -d "$filename" ];then
@@ -119,7 +137,7 @@ commonHeader "200" "OK"
case "${filename##*.}" in
"htsh") echo -e "Content-Type: text/html\r"
echo -e "\r"
- /usr/bin/htsh "$filename" "`echo $var_str`"
+ /usr/bin/htsh "$filename" "$var_str" #"`echo $var_str`"
;;
"sh") echo -e "Content-Type: text/html\r"
echo -e "\r"

0 comments on commit f3b2dbf

Please sign in to comment.