flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 4b85797053e9433b25d6961b53092975a66c6a45
parent 56777472e76955038796df889db7e26fed227dcb
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 24 Oct 2020 11:29:28 -0700

clean filepaths

Diffstat:
Mhttp.go | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/http.go b/http.go @@ -116,6 +116,7 @@ func uploadFilesHandler(w http.ResponseWriter, r *http.Request) { authUser := "alex" r.ParseMultipartForm(10 << 20) file, fileHeader, err := r.FormFile("file") + fileName := filepath.Clean(fileHeader.Filename) defer file.Close() if err != nil { log.Println(err) @@ -125,13 +126,13 @@ func uploadFilesHandler(w http.ResponseWriter, r *http.Request) { var dest []byte file.Read(dest) log.Println("asdfadf") - err = checkIfValidFile(fileHeader.Filename, dest) + err = checkIfValidFile(fileName, dest) if err != nil { log.Println(err) renderError(w, err.Error(), 400) return } - destPath := path.Join(c.FilesDirectory, authUser, fileHeader.Filename) + destPath := path.Join(c.FilesDirectory, authUser, fileName) f, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE, 0644) if err != nil {