diff --git a/README.md b/README.md index 64a5c6c..7a38d38 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 diff --git a/bashttpd b/bashttpd index 3f6090f..3eabe57 100755 --- a/bashttpd +++ b/bashttpd @@ -205,8 +205,14 @@ 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" + 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 ]] && \