* fixed bugs in session_get_username() and the cookie handler

merge-requests/2/head
Dominika Liberda 2021-01-15 20:23:21 +01:00
parent fe02fa38a3
commit c02cf1b2ae
3 changed files with 7 additions and 6 deletions

View File

@ -1,9 +1,9 @@
declare -A cfg
cfg[ip]=127.0.0.1 # IP address to bind to - use 0.0.0.0 to bind to all
cfg[ip]=0.0.0.0 # IP address to bind to - use 0.0.0.0 to bind to all
cfg[http]=true # enables/disables listening on HTTP
cfg[port]=1337 # HTTP port
cfg[port]=1341 # HTTP port
cfg[namespace]='app'

View File

@ -74,7 +74,7 @@ function session_get_username() {
[[ "$1" == "" ]] && return
IFS=':'
local data=($(grep ":$1" secret/users.dat))
local data=($(grep ":$1$" secret/users.dat))
unset IFS
echo ${data[0]}
}

View File

@ -54,9 +54,10 @@ while read param; do
r[authorization]="$(printf "$param" | sed 's/Authorization: Bearer //;s/\r//')"
elif [[ "$param" == *"Cookie: "* ]]; then
for i in $(echo $param | sed -E 's/Cookie: //;s/\;//g;s/%/\\x/g'); do
name="$(echo $i | sed -E 's/\=(.*)$//')"
value="$(echo $i | sed -E 's/^(.*)\=//')"
IFS=';'
for i in $(IFS=' '; echo "$param" | sed -E 's/Cookie: //;;s/%/\\x/g'); do
name="$((grep -Poh ".*?(?==)" | head -1) <<< $i)"
value="$(sed "s/$name=//" <<< $i)"
cookies[$name]="$(echo -e $value)"
done