-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for uploading compressed files and misc application types
- Loading branch information
Colas Nahaboo
committed
Dec 13, 2017
1 parent
b4ca0c5
commit 6ffee34
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Local file upload interactive test | ||
To use this test: | ||
- copy cgibashopts-local.cgi and cgibashopts into a place in your local web server where .cgi files are executed as cgi | ||
- place the various files to test the upload of in `/tmp` | ||
- open cgibashopts-local.cgi in your browser, e.g: http://localhost/cgi-bin/cgibashopts-local.cgi | ||
- upload them via the web page: On each upload of a file, the script will compare the uploaded copy to its source in /tmp and display the result | ||
|
||
This is a (semi-)manual test, but exercising a real web server and browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -u | ||
set -e | ||
. cgibashopts | ||
|
||
title="CGI BASH opts upload test on a local host" | ||
header="Content-Type: text/html$nl$nl<html><head><title>$title</title> | ||
</head><body><h1>$title</h1>" | ||
footer="" | ||
|
||
################################# Options | ||
export data=/tmp/cgibashopts-formfiletest.data | ||
err() { echo "***ERROR: $*" >&2; exit -1; } | ||
|
||
################################# Code | ||
main() { | ||
echo "$header" | ||
if [ -n "${FORM_file:-}" ]; then | ||
src="/tmp/${FORM_file##*/}" | ||
[ "$FORMFILES" = file ] || echo "<p>***Error, FORMFILES=$FORMFILES</p>" | ||
if [ -e "$CGIBASHOPTS_DIR/file" ]; then | ||
if [ -s "$CGIBASHOPTS_DIR/file" ]; then | ||
if [ -s "$src" ]; then | ||
if cmp -s "$src" "$CGIBASHOPTS_DIR/file"; then | ||
echo "<p>Upload of $src successful</p>" | ||
else | ||
echo "<p>***Error, file uploaded differ</p>" | ||
fi | ||
else | ||
echo "<p>***Error, src file empty</p>" | ||
fi | ||
else | ||
echo "<p>***Error, file uploaded empty</p>" | ||
fi | ||
else | ||
echo "<p>***Error no uploaded file!</p>" | ||
fi | ||
fi | ||
form_page | ||
} | ||
|
||
form_page() { | ||
echo "<form method=POST enctype='multipart/form-data'> | ||
<br>File: <input type=file name=file size=32> | ||
<br><input type=submit value=Upload> | ||
</form>" | ||
echo "$footer" | ||
} | ||
|
||
main |