From 4f060433dfc3b40b4716897fe5091ad8db127a9e Mon Sep 17 00:00:00 2001 From: Colas Nahaboo Date: Tue, 9 Oct 2018 18:04:28 +0200 Subject: [PATCH] Version 2: fix, spaces in parameter values could be seen as + --- README.md | 1 + cgibashopts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0057415..e08f89a 100644 --- a/README.md +++ b/README.md @@ -49,5 +49,6 @@ E.g: `source /usr/local/bin/cgibashopts` or A test suite is provided, see the README.md in directory `test-suite` ## History of changes +- 2018-10-09 Version 2: fix, spaces in parameter values could be seen as + - 2017-12-13 Version 1: fixes for upload of files with various mime-types, library can now be used in scripts using set -u and set -e. - 2017-12-07 Creation of the project diff --git a/cgibashopts b/cgibashopts index 84c1f2d..ff87304 100755 --- a/cgibashopts +++ b/cgibashopts @@ -3,7 +3,7 @@ # See https://github.com/ColasNahaboo/cgibashopts # Uses the CGI env variables REQUEST_METHOD CONTENT_TYPE QUERY_STRING -export CGIBASHOPTS_VERSION=1 +export CGIBASHOPTS_VERSION=2 cr=$'\r' nl=$'\n' export FORMS= @@ -57,7 +57,7 @@ if [ "${REQUEST_METHOD:-}" = POST ]; then if [[ $line =~ ^Content-Disposition:\ *form-data\;\ *name=\"([^\"]+)\"(\;\ *filename=\"([^\"]+)\")? ]]; then var="${BASH_REMATCH[1]}" val="${BASH_REMATCH[3]}" - [[ $val =~ % ]] && val=$(urldecode "$val") + [[ $val =~ [%+] ]] && val=$(urldecode "$val") type= read -r line while [ -n "$line" ]; do @@ -119,7 +119,7 @@ if [[ $s =~ = ]]; then # modern & (or ;) separated list of key=value val="${BASH_REMATCH[2]}" s="${BASH_REMATCH[3]}" if [[ $var =~ ^[_[:alpha:]] ]]; then # ignore invalid vars - [[ $val =~ % ]] && val=$(urldecode "$val") + [[ $val =~ [%+] ]] && val=$(urldecode "$val") FORMS="$FORMS${FORMS:+ }$var" declare -x FORM_$var="$val" fi