Fix: Double encoding of URLs when using data proxy (#98494)

fix: unescape raw path and set to req path
This commit is contained in:
Syerikjan Kh
2025-01-07 10:27:34 -05:00
committed by GitHub
parent 44e65c5bc9
commit b7809b7350
2 changed files with 22 additions and 2 deletions
+8 -2
View File
@@ -32,7 +32,6 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
}
ctxLogger := logger.FromContext(ctx)
if len(route.URL) > 0 {
interpolatedURL, err := interpolateString(route.URL, data)
if err != nil {
@@ -49,7 +48,14 @@ func ApplyRoute(ctx context.Context, req *http.Request, proxyPath string, route
req.URL.Scheme = routeURL.Scheme
req.URL.Host = routeURL.Host
req.Host = routeURL.Host
req.URL.Path = util.JoinURLFragments(routeURL.Path, proxyPath)
req.URL.RawPath = util.JoinURLFragments(routeURL.Path, proxyPath)
unescapedPath, err := url.PathUnescape(req.URL.RawPath)
if err != nil {
ctxLogger.Error("Failed to unescape raw path", "rawPath", req.URL.RawPath, "error", err)
return
}
req.URL.Path = unescapedPath
}
if err := addQueryString(req, route, data); err != nil {