fix: clean request path before acls (#1055)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Stavros
2026-07-30 19:35:31 +03:00
committed by GitHub
co-authored by Claude Fable 5
parent cbd92a1104
commit 6d5563db2c
5 changed files with 192 additions and 5 deletions
+14
View File
@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"net/url"
"path"
"regexp"
"strings"
@@ -551,6 +552,19 @@ func (controller *ProxyController) getProxyContext(c *gin.Context) (ProxyContext
return ProxyContext{}, err
}
// remove any query params from the request path
upath, err := url.Parse(ctx.Path)
if err != nil {
return ProxyContext{}, fmt.Errorf("failed to parse request path: %v", err)
}
if upath.Host != "" || !strings.HasPrefix(upath.Path, "/") {
return ProxyContext{}, fmt.Errorf("invalid request path")
}
ctx.Path = path.Clean(upath.Path)
// We don't care if the header is empty, we will just assume it's not a browser
userAgent, _ := controller.getHeader(c, "user-agent")
isBrowser := BrowserUserAgentRegex.MatchString(userAgent)