Skip to content

Commit

Permalink
ensure id is uri decoded
Browse files Browse the repository at this point in the history
  • Loading branch information
Son Roy Almerol committed Nov 29, 2024
1 parent 523db72 commit 948bc40
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
24 changes: 21 additions & 3 deletions internal/proxy/controllers/exclusions/exclusions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
25 changes: 22 additions & 3 deletions internal/proxy/controllers/partial_files/partial_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 948bc40

Please sign in to comment.