diff --git a/internal/proxy/controllers/exclusions/exclusions.go b/internal/proxy/controllers/exclusions/exclusions.go index a01fbcd..7733125 100644 --- a/internal/proxy/controllers/exclusions/exclusions.go +++ b/internal/proxy/controllers/exclusions/exclusions.go @@ -5,6 +5,7 @@ package exclusions import ( "encoding/json" "net/http" + "net/url" "github.com/sonroyaalmerol/pbs-plus/internal/proxy" "github.com/sonroyaalmerol/pbs-plus/internal/proxy/controllers" @@ -112,7 +113,12 @@ func ExtJsExclusionSingleHandler(storeInstance *store.Store) func(http.ResponseW return } - exclusion, err := storeInstance.GetExclusion(pathVar["exclusion"]) + pathDecoded, err := url.QueryUnescape(pathVar["exclusion"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + exclusion, err := storeInstance.GetExclusion(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return @@ -157,7 +163,13 @@ func ExtJsExclusionSingleHandler(storeInstance *store.Store) func(http.ResponseW } if r.Method == http.MethodGet { - exclusion, err := storeInstance.GetExclusion(pathVar["exclusion"]) + pathDecoded, err := url.QueryUnescape(pathVar["exclusion"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + + exclusion, err := storeInstance.GetExclusion(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return @@ -174,7 +186,13 @@ func ExtJsExclusionSingleHandler(storeInstance *store.Store) func(http.ResponseW } if r.Method == http.MethodDelete { - err := storeInstance.DeleteExclusion(pathVar["exclusion"]) + pathDecoded, err := url.QueryUnescape(pathVar["exclusion"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + + err = storeInstance.DeleteExclusion(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return diff --git a/internal/proxy/controllers/partial_files/partial_files.go b/internal/proxy/controllers/partial_files/partial_files.go index 8c64391..7baf67c 100644 --- a/internal/proxy/controllers/partial_files/partial_files.go +++ b/internal/proxy/controllers/partial_files/partial_files.go @@ -5,6 +5,7 @@ package partial_files import ( "encoding/json" "net/http" + "net/url" "github.com/sonroyaalmerol/pbs-plus/internal/proxy" "github.com/sonroyaalmerol/pbs-plus/internal/proxy/controllers" @@ -111,7 +112,13 @@ func ExtJsPartialFileSingleHandler(storeInstance *store.Store) func(http.Respons return } - partialFile, err := storeInstance.GetPartialFile(pathVar["partial_file"]) + pathDecoded, err := url.QueryUnescape(pathVar["partial_file"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + + partialFile, err := storeInstance.GetPartialFile(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return @@ -151,7 +158,13 @@ func ExtJsPartialFileSingleHandler(storeInstance *store.Store) func(http.Respons } if r.Method == http.MethodGet { - partial_file, err := storeInstance.GetPartialFile(pathVar["partial_file"]) + pathDecoded, err := url.QueryUnescape(pathVar["partial_file"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + + partial_file, err := storeInstance.GetPartialFile(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return @@ -168,7 +181,13 @@ func ExtJsPartialFileSingleHandler(storeInstance *store.Store) func(http.Respons } if r.Method == http.MethodDelete { - err := storeInstance.DeletePartialFile(pathVar["partial_file"]) + pathDecoded, err := url.QueryUnescape(pathVar["partial_file"]) + if err != nil { + controllers.WriteErrorResponse(w, err) + return + } + + err = storeInstance.DeletePartialFile(pathDecoded) if err != nil { controllers.WriteErrorResponse(w, err) return