From c2e0143bfe35b539bdbec9971e83fa9f9ab78034 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 9 Aug 2023 14:57:45 +0800 Subject: Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392) Fix #26389 And complete an old TODO: `ctx.Params does un-escaping,..., which is incorrect.` --- modules/context/base.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/context/base.go b/modules/context/base.go index 83e5a214f8..8df1dde866 100644 --- a/modules/context/base.go +++ b/modules/context/base.go @@ -147,6 +147,10 @@ func (b *Base) Params(p string) string { return s } +func (b *Base) PathParamRaw(p string) string { + return chi.URLParam(b.Req, strings.TrimPrefix(p, ":")) +} + // ParamsInt64 returns the param on route as int64 func (b *Base) ParamsInt64(p string) int64 { v, _ := strconv.ParseInt(b.Params(p), 10, 64) -- cgit v1.2.3