Skip to content

Commit da74d54

Browse files
committed
upload example done i think
1 parent 8199e42 commit da74d54

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

core.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ EOF
183183
BOUNDARY="${BOUNDARY#*=}"
184184
fi
185185

186-
187186
# Read cookies (yum!)
188187
if [[ ! -z "${HTTP_HEADERS["Cookie"]}" ]]; then
189188
while read -r -d ';' line; do
@@ -197,6 +196,19 @@ EOF
197196

198197
# Read multipart body
199198
if [[ ! -z "$BOUNDARY" ]]; then
199+
route_script=`matchRoute "$REQUEST_PATH"`
200+
ALLOW_UPLOADS=false
201+
if directive_test=$(head -1 "pages/${route_script}"); then
202+
if [[ "$directive_test" == "# allow-uploads" ]]; then
203+
ALLOW_UPLOADS=true
204+
fi
205+
fi
206+
if [[ "$ALLOW_UPLOADS" != "true" ]]; then
207+
printf "%s\r\n" "HTTP/1.1 403 Forbidden"
208+
printf "%s\r\n" "Server: bash lol"
209+
printf "%s\r\n" ""
210+
return
211+
fi
200212
state="start"
201213
reader="reading"
202214
local -A MULTIPART_HEADERS

examples/file-upload/pages/upload.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
# allow-uploads
12

2-
debug "hello"
33
echo "<pre>"
44
printf "%s\n" "${FILE_UPLOADS[@]@K}"
55
printf "%s\n" "${FILE_UPLOAD_NAMES[@]@K}"

0 commit comments

Comments
 (0)