# HG changeset patch # User Christophe Lincoln # Date 1397536716 -7200 # Node ID 0a476090cd091060e65b57322936b632850c0af1 # Parent 178de496f806fc837696d66e9992ca113c7edefd Rewrite CGI directory lister diff -r 178de496f806 -r 0a476090cd09 rootfs/var/www/cgi-bin/index.cgi --- a/rootfs/var/www/cgi-bin/index.cgi Sun Apr 13 01:36:58 2014 +0200 +++ b/rootfs/var/www/cgi-bin/index.cgi Tue Apr 15 06:38:36 2014 +0200 @@ -1,46 +1,54 @@ #!/bin/sh -. /lib/libtaz.sh +# +# Directory lister for BusyBox HTTPd +# Copyright (C) 2014 SliTaz GNU/Linux - BSD License +# +. /usr/lib/slitaz/httphelper.sh +header -# Internationalization. -TEXTDOMAIN='slitaz-base' -. /etc/locale.conf -export TEXTDOMAIN LANG +# Security check +case "$QUERY_STRING" in + ..*) echo "Security exit" && exit 1 ;; +esac -if [ ! -d ..$QUERY_STRING ]; then - echo "HTTP/1.1 404 Not Found"; -else - title=$(_ 'Index of $QUERY_STRING') - cat << EOT -Content-type: text/html +# Html5 head +cat << EOT + + + + + Index of /$QUERY_STRING + + + + + +
+
Files: $(ls ../$QUERY_STRING | wc -l)
+ +
+ EOT -fi