diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-09 14:57:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 14:57:45 +0800 |
commit | c2e0143bfe35b539bdbec9971e83fa9f9ab78034 (patch) | |
tree | a56e4fad747108e8bdd7b801fe82cf4458e76b19 /modules/context/base.go | |
parent | 906e253d5e596d258c1afad7cfd9f8fb3ba3b2b5 (diff) | |
download | gitea-c2e0143bfe35b539bdbec9971e83fa9f9ab78034.tar.gz gitea-c2e0143bfe35b539bdbec9971e83fa9f9ab78034.zip |
Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392)
Fix #26389
And complete an old TODO: `ctx.Params does un-escaping,..., which is
incorrect.`
Diffstat (limited to 'modules/context/base.go')
-rw-r--r-- | modules/context/base.go | 4 |
1 files changed, 4 insertions, 0 deletions
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) |