set all variables to local

This commit is contained in:
overflowerror 2022-03-30 21:33:14 +02:00
parent 10b8f41076
commit 2b86c44b22
7 changed files with 24 additions and 19 deletions

View file

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
getCookie() { getCookie() {
key="$1" local key="$1"
echo "$HTTP_COOKIE" | tr ';' $'\n' | grep -e "^$1=" | cut -d= -f2 | sed -r 's/\s*$//g' echo "$HTTP_COOKIE" | tr ';' $'\n' | grep -e "^$1=" | cut -d= -f2 | sed -r 's/\s*$//g'
} }
setCookie() { setCookie() {
key="$1" local key="$1"
value="$2" local value="$2"
attributes="$3" local attributes="$3"
header "Set-Cookie" "$key=$value; $attributes" header "Set-Cookie" "$key=$value; $attributes"
} }

View file

@ -26,16 +26,15 @@ query() {
escape() { escape() {
echo "$1" | echo "$1" |
sed "s/\\/\\\\/g" | sed 's/\\/\\\\/g' |
sed "s/'/\\'/g" | sed "s/'/\\'/g" |
sed "s/\"/\\\"/g" | sed 's/\"/\\\"/g' |
sed "s/\n/\\n/g" | sed 's/\n/\\n/g' |
sed "s/\r/\\r/g" | sed 's/\r/\\r/g' |
sed "s/\t/\\t/g" | sed 's/\t/\\t/g' |
sed "s/\Z/\\Z/g" | sed 's/\Z/\\Z/g' |
sed "s/\b/\\b/g" | sed 's/%/\\%/g' |
sed "s/%/\\%/g" | sed 's/_/\\_/g'
sed "s/_/\\_/g"
} }
getColumns() { getColumns() {

View file

@ -20,8 +20,8 @@ _default404() {
} }
_matchPaths() { _matchPaths() {
actual="$1" local actual="$1"
search="$2" local search="$2"
# TODO: add wildcards # TODO: add wildcards
test "$actual" = "$search" test "$actual" = "$search"

View file

@ -32,8 +32,8 @@ _getSession() {
} }
_newSessionId() { _newSessionId() {
base="$(date -Ins -u)" local base="$(date -Ins -u)"
random="$RANDOM" local random="$RANDOM"
while _getSession "$(echo "$base$random" | md5sum | cut -d' ' -f1)" > /dev/null; do while _getSession "$(echo "$base$random" | md5sum | cut -d' ' -f1)" > /dev/null; do
random="$RANDOM" random="$RANDOM"
done done

@ -1 +1 @@
Subproject commit 6b398f25719243c102f7a91972966538ed23dd01 Subproject commit 0964fdc24ff68d84f419354f227b12cb9ff27df3

6
uri.sh
View file

@ -17,6 +17,12 @@ queryString() {
_formData="" _formData=""
cacheFormData() {
if test -z "$_formData"; then
_formData="$(cat)"
fi
}
formData() { formData() {
if test -z "$_formData"; then if test -z "$_formData"; then
_formData="$(cat)" _formData="$(cat)"

View file

@ -4,7 +4,7 @@ _hasStatus=0
status() { status() {
_hasStatus=1 _hasStatus=1
status="$1" local status="$1"
echo -n "Status: $status " echo -n "Status: $status "
case "$status" in case "$status" in
100) echo "Continue" ;; 100) echo "Continue" ;;