Skip to content

Commit

Permalink
Version 2: fix, spaces in parameter values could be seen as +
Browse files Browse the repository at this point in the history
  • Loading branch information
ColasNahaboo committed Oct 9, 2018
1 parent 70f6d66 commit 4f06043
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions cgibashopts
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f06043

Please sign in to comment.