summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-08-09 14:57:45 +0800
committerGitHub <noreply@github.com>2023-08-09 14:57:45 +0800
commitc2e0143bfe35b539bdbec9971e83fa9f9ab78034 (patch)
treea56e4fad747108e8bdd7b801fe82cf4458e76b19 /routers
parent906e253d5e596d258c1afad7cfd9f8fb3ba3b2b5 (diff)
downloadgitea-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 'routers')
-rw-r--r--routers/api/v1/repo/wiki.go8
-rw-r--r--routers/web/repo/wiki.go12
2 files changed, 10 insertions, 10 deletions
diff --git a/routers/api/v1/repo/wiki.go b/routers/api/v1/repo/wiki.go
index e33790a378..7f3a7d0674 100644
--- a/routers/api/v1/repo/wiki.go
+++ b/routers/api/v1/repo/wiki.go
@@ -127,7 +127,7 @@ func EditWikiPage(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.CreateWikiPageOptions)
- oldWikiName := wiki_service.WebPathFromRequest(ctx.Params(":pageName"))
+ oldWikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw(":pageName"))
newWikiName := wiki_service.UserTitleToWebPath("", form.Title)
if len(newWikiName) == 0 {
@@ -231,7 +231,7 @@ func DeleteWikiPage(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- wikiName := wiki_service.WebPathFromRequest(ctx.Params(":pageName"))
+ wikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw(":pageName"))
if err := wiki_service.DeleteWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, wikiName); err != nil {
if err.Error() == "file does not exist" {
@@ -359,7 +359,7 @@ func GetWikiPage(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
// get requested pagename
- pageName := wiki_service.WebPathFromRequest(ctx.Params(":pageName"))
+ pageName := wiki_service.WebPathFromRequest(ctx.PathParamRaw(":pageName"))
wikiPage := getWikiPage(ctx, pageName)
if !ctx.Written() {
@@ -409,7 +409,7 @@ func ListPageRevisions(ctx *context.APIContext) {
}
// get requested pagename
- pageName := wiki_service.WebPathFromRequest(ctx.Params(":pageName"))
+ pageName := wiki_service.WebPathFromRequest(ctx.PathParamRaw(":pageName"))
if len(pageName) == 0 {
pageName = "Home"
}
diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go
index e3c187c33b..4de24e2a38 100644
--- a/routers/web/repo/wiki.go
+++ b/routers/web/repo/wiki.go
@@ -185,7 +185,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
ctx.Data["Pages"] = pages
// get requested page name
- pageName := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ pageName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
if len(pageName) == 0 {
pageName = "Home"
}
@@ -332,7 +332,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
}
// get requested pagename
- pageName := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ pageName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
if len(pageName) == 0 {
pageName = "Home"
}
@@ -415,7 +415,7 @@ func renderEditPage(ctx *context.Context) {
}()
// get requested pagename
- pageName := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ pageName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
if len(pageName) == 0 {
pageName = "Home"
}
@@ -647,7 +647,7 @@ func WikiRaw(ctx *context.Context) {
return
}
- providedWebPath := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ providedWebPath := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
providedGitPath := wiki_service.WebPathToGitPath(providedWebPath)
var entry *git.TreeEntry
if commit != nil {
@@ -759,7 +759,7 @@ func EditWikiPost(ctx *context.Context) {
return
}
- oldWikiName := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ oldWikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
newWikiName := wiki_service.UserTitleToWebPath("", form.Title)
if len(form.Message) == 0 {
@@ -778,7 +778,7 @@ func EditWikiPost(ctx *context.Context) {
// DeleteWikiPagePost delete wiki page
func DeleteWikiPagePost(ctx *context.Context) {
- wikiName := wiki_service.WebPathFromRequest(ctx.Params("*"))
+ wikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("*"))
if len(wikiName) == 0 {
wikiName = "Home"
}