url decode filename

This commit is contained in:
milarin 2023-02-16 14:08:01 +01:00
parent ada3580a85
commit 10e3025ddc

View File

@ -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))