Skip to content

Commit 4298560

Browse files
committed
Prevent double decoding of % in url params
There was an unfortunate regression in #14293 which has led to the double decoding of url parameter elements if they contain a '%'. This is due to an issue with the way chi decodes its RoutePath. In detail the problem lies in mux.go where the routeHTTP path uses the URL.RawPath or even the URL.Path instead of the escaped path to do routing. This PR simply forcibly sets the routePath to that of the EscapedPath. Fix #17938 Signed-off-by: Andrew Thornton <[email protected]>
1 parent f58e687 commit 4298560

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

modules/context/context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ func Contexter() func(next http.Handler) http.Handler {
609609
var locale = middleware.Locale(resp, req)
610610
var startTime = time.Now()
611611
var link = setting.AppSubURL + strings.TrimSuffix(req.URL.EscapedPath(), "/")
612+
613+
chiCtx := chi.RouteContext(req.Context())
614+
chiCtx.RoutePath = req.URL.EscapedPath()
615+
612616
var ctx = Context{
613617
Resp: NewResponse(resp),
614618
Cache: mc.GetCache(),

0 commit comments

Comments
 (0)