mirror of
https://github.com/nais/wonderwall.git
synced 2026-08-23 21:16:14 +00:00
fix(all): use url.ParseRequestURI instead of just url.Parse where necessary
This commit is contained in:
@@ -137,7 +137,7 @@ func (h Handler) defaultErrorResponse(w http.ResponseWriter, r *http.Request, st
|
||||
}
|
||||
|
||||
func (h Handler) customErrorRedirect(w http.ResponseWriter, r *http.Request, statusCode int) error {
|
||||
override, err := url.Parse(h.GetErrorPath())
|
||||
override, err := url.ParseRequestURI(h.GetErrorPath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func CanonicalRedirect(r *http.Request) string {
|
||||
return ingressPath
|
||||
}
|
||||
|
||||
parsed, err := url.Parse(redirect)
|
||||
parsed, err := url.ParseRequestURI(redirect)
|
||||
if err != nil {
|
||||
// Silently fall back to ingress path
|
||||
return ingressPath
|
||||
|
||||
@@ -102,6 +102,16 @@ func TestCanonicalRedirect(t *testing.T) {
|
||||
value: "/path?gnu=notunix",
|
||||
expected: "/path?gnu=notunix",
|
||||
},
|
||||
{
|
||||
name: "relative path",
|
||||
value: "path",
|
||||
expected: "/some-path", // should fall back to default path
|
||||
},
|
||||
{
|
||||
name: "relative path with query parameters",
|
||||
value: "path?gnu=notunix",
|
||||
expected: "/some-path", // should fall back to default path
|
||||
},
|
||||
{
|
||||
name: "url encoded path",
|
||||
value: "%2Fpath",
|
||||
|
||||
@@ -119,7 +119,7 @@ func ParseIngress(ingress string) (*Ingress, error) {
|
||||
return nil, fmt.Errorf("ingress cannot be empty")
|
||||
}
|
||||
|
||||
u, err := url.Parse(ingress)
|
||||
u, err := url.ParseRequestURI(ingress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user