From 7ce8957a6a6dbeb763cfeef612928c5858f213c4 Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Thu, 20 Sep 2012 07:06:34 -0500 Subject: [PATCH 1/3] Fix wording in README.md Thanks to notwa for noticing I had forgotten a word. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bc8e31..67b9d80 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Limitations: 2. Doesn't strictly adhere to the HTTP spec. Security: - 1. Only rudimentary input handling. We would not running this on a public machine. + 1. Only rudimentary input handling. We would not recommend running this on a public machine. HTTP protocol support: 403: Returned when a directory is not listable, or a file is not readable From 85b912ecc4c9cec14b3e2f502ebded699e81ae35 Mon Sep 17 00:00:00 2001 From: lbourne43 Date: Thu, 23 Jan 2014 09:12:12 +0000 Subject: [PATCH 2/3] Added support for index.htm files Changed serve_file_from_dir to check for index.html then fall back to checking for index.htm --- bashttpd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bashttpd b/bashttpd index 3f6090f..675744f 100755 --- a/bashttpd +++ b/bashttpd @@ -205,8 +205,13 @@ serve_dir_or_file_from() { [[ $URL_PATH == *..* ]] && fail_with 400 # Serve index file if exists in requested directory - [[ -d $URL_PATH && -f $URL_PATH/index.html && -r $URL_PATH/index.html ]] && \ - URL_PATH="$URL_PATH/index.html" + if [[ -d $URL_PATH ]]; then + if [[ -f $URL_PATH/index.html && -r $URL_PATH/index.html ]]; then + URL_PATH="$URL_PATH/index.html" + elif [[ -f $URL_PATH/index.htm && -r $URL_PATH/index.htm ]]; then + URL_PATH="$URL_PATH/index.htm" + fi + fi if [[ -f $URL_PATH ]]; then [[ -r $URL_PATH ]] && \ From 0085e9d4765a4fdafc8c0dfcd4fbd4d4f1c784a0 Mon Sep 17 00:00:00 2001 From: lbourne43 Date: Mon, 27 Jan 2014 09:08:59 +0000 Subject: [PATCH 3/3] Update bashttpd --- bashttpd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bashttpd b/bashttpd index 675744f..3eabe57 100755 --- a/bashttpd +++ b/bashttpd @@ -205,14 +205,15 @@ serve_dir_or_file_from() { [[ $URL_PATH == *..* ]] && fail_with 400 # Serve index file if exists in requested directory - if [[ -d $URL_PATH ]]; then - if [[ -f $URL_PATH/index.html && -r $URL_PATH/index.html ]]; then - URL_PATH="$URL_PATH/index.html" - elif [[ -f $URL_PATH/index.htm && -r $URL_PATH/index.htm ]]; then - URL_PATH="$URL_PATH/index.htm" - fi + FILE_LIST=('index.html' 'index.htm') + if [[ -d "$URL_PATH" ]]; then + for FILE in "${FILE_LIST[@]}"; do + [[ -f "$URL_PATH/$FILE" && -r "$URL_PATH/$FILE" ]] && \ + URL_PATH="$URL_PATH/$FILE" && break + done fi + if [[ -f $URL_PATH ]]; then [[ -r $URL_PATH ]] && \ serve_file "$URL_PATH" "$@" || fail_with 403