Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode the URI before handling it. #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bashttpd
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ unconditionally() {
"$@" "$REQUEST_URI"
}

# Taken from https://stackoverflow.com/a/6265305/566849
uri_decode() {
echo -e "$(sed 's/+/ /g;s/%\(..\)/\\x\1/g;')"
}

# Request-Line HTTP RFC 2616 $5.1
read -r line || fail_with 400

Expand All @@ -266,6 +271,8 @@ read -r REQUEST_METHOD REQUEST_URI REQUEST_HTTP_VERSION <<<"$line"
# Only GET is supported at this time
[ "$REQUEST_METHOD" = "GET" ] || fail_with 405

REQUEST_URI=$(uri_decode <<<"$REQUEST_URI")

declare -a REQUEST_HEADERS

while read -r line; do
Expand Down