Commit c02cf1b2 authored by Dominika Liberda's avatar Dominika Liberda 💽

* fixed bugs in session_get_username() and the cookie handler

parent fe02fa38
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'
......
......@@ -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]}
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment