From 10e3025ddcf23c1e737bb1d0dabda77913752067 Mon Sep 17 00:00:00 2001 From: milarin Date: Thu, 16 Feb 2023 14:08:01 +0100 Subject: [PATCH] url decode filename --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 2ae3f25..d036229 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "fmt" "math/rand" "net/http" + "net/url" "os" "os/exec" "path/filepath" @@ -140,8 +141,12 @@ func GetAllFilesHandler(w http.ResponseWriter, r *http.Request) { } func GetEncodeFileHandler(w http.ResponseWriter, r *http.Request) { - fileName := mux.Vars(r)["file"] format := mux.Vars(r)["format"] + fileName, err := url.QueryUnescape(mux.Vars(r)["file"]) + if err != nil { + InternalServerError(w, err) + return + } inputFilePath := filepath.Join(LibraryPath, ".songs", fileName) outputFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("%d.%s", rand.Int(), format))