Skip to content

Commit

Permalink
Allow whitespace in filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
mprimi committed Jun 29, 2022
1 parent 9218307 commit aa619e5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commands/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func handleFilesUpload(w http.ResponseWriter, req *http.Request, bundleName stri
func makeHandler(prefix string) (func(w http.ResponseWriter, req *http.Request)) {

kBundleNameRe := "[a-zA-Z0-9_\\.\\-]{4,128}"
kFileNameRe := "[a-zA-Z0-9_\\.\\-]{4,128}"
kFileNameRe := "[a-zA-Z0-9_\\.\\-\\ ]{4,128}"

rootRe := regexp.MustCompile("^" + prefix + "$")
listBundleRe := regexp.MustCompile("^" + prefix + "bundle/(" + kBundleNameRe + ")/?$")
Expand Down
36 changes: 36 additions & 0 deletions smoke-tests/test-web-send-receive-whitespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/util.sh

# --

BUNDLE_NAME="web-send-receive-test-whitespace-$((RANDOM))"
F1=README.md
F1_WITH_SPACES="READ ME.md"

# Create a file with spaces in name
cp ${NASEFA_ROOT}/${F1} "${TEMPDIR}/${F1_WITH_SPACES}"


PORT=8081

${NASEFA} web -bindAddr ":${PORT}" &
WEB_PID=${!}
log_debug "Started web, PID: ${WEB_PID}"

${NASEFA} create -bundleName ${BUNDLE_NAME}
log_debug "Bundle created: ${BUNDLE_NAME}"

curl -s -F "file1=@${TEMPDIR}/${F1_WITH_SPACES}" http://localhost:${PORT}/upload/${BUNDLE_NAME} >/dev/null || fail "Failed to upload files"
log_debug "Uploaded 1 file with spaces"

curl -s "http://localhost:${PORT}/bundle/${BUNDLE_NAME}/${F1_WITH_SPACES}" > ${TEMPDIR}/${F1} || fail "Failed to download file"
log_debug "Downloaded 1 file (saved without spaces)"

kill ${WEB_PID}
wait ${WEB_PID} || echo "Web shut down"

check_files ${NASEFA_ROOT} ${TEMPDIR} ${F1}

0 comments on commit aa619e5

Please sign in to comment.