diff --git a/.air.toml b/.air.toml index 3740c4d4aa391..8854041a25b92 100644 --- a/.air.toml +++ b/.air.toml @@ -21,3 +21,6 @@ exclude_dir = [ ] exclude_regex = ["_test.go$", "_gen.go$"] stop_on_error = true + +[log] +main_only = true diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 9bd27329892a9..5ed277945e7fe 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -27,7 +27,6 @@ plugins: - eslint-plugin-array-func - eslint-plugin-github - eslint-plugin-i - - eslint-plugin-jquery - eslint-plugin-no-jquery - eslint-plugin-no-use-extend-native - eslint-plugin-regexp @@ -45,6 +44,7 @@ overrides: - files: ["web_src/**/*"] globals: __webpack_public_path__: true + htmx: true process: false # https://github.com/webpack/webpack/issues/15833 - files: ["web_src/**/*", "docs/**/*"] env: @@ -308,55 +308,6 @@ rules: i/prefer-default-export: [0] i/unambiguous: [0] init-declarations: [0] - jquery/no-ajax-events: [2] - jquery/no-ajax: [2] - jquery/no-animate: [2] - jquery/no-attr: [2] - jquery/no-bind: [2] - jquery/no-class: [0] - jquery/no-clone: [2] - jquery/no-closest: [0] - jquery/no-css: [2] - jquery/no-data: [0] - jquery/no-deferred: [2] - jquery/no-delegate: [2] - jquery/no-each: [0] - jquery/no-extend: [2] - jquery/no-fade: [2] - jquery/no-filter: [0] - jquery/no-find: [0] - jquery/no-global-eval: [2] - jquery/no-grep: [2] - jquery/no-has: [2] - jquery/no-hide: [2] - jquery/no-html: [0] - jquery/no-in-array: [2] - jquery/no-is-array: [2] - jquery/no-is-function: [2] - jquery/no-is: [2] - jquery/no-load: [2] - jquery/no-map: [2] - jquery/no-merge: [2] - jquery/no-param: [2] - jquery/no-parent: [0] - jquery/no-parents: [2] - jquery/no-parse-html: [2] - jquery/no-prop: [2] - jquery/no-proxy: [2] - jquery/no-ready: [2] - jquery/no-serialize: [2] - jquery/no-show: [2] - jquery/no-size: [2] - jquery/no-sizzle: [2] - jquery/no-slide: [2] - jquery/no-submit: [2] - jquery/no-text: [2] - jquery/no-toggle: [2] - jquery/no-trigger: [0] - jquery/no-trim: [2] - jquery/no-val: [0] - jquery/no-when: [2] - jquery/no-wrap: [2] line-comment-position: [0] logical-assignment-operators: [0] max-classes-per-file: [0] @@ -766,6 +717,7 @@ rules: unicorn/no-lonely-if: [2] unicorn/no-magic-array-flat-depth: [0] unicorn/no-negated-condition: [0] + unicorn/no-negation-in-equality-check: [2] unicorn/no-nested-ternary: [0] unicorn/no-new-array: [0] unicorn/no-new-buffer: [0] diff --git a/Dockerfile b/Dockerfile index 21a8ce0d7599b..6621dded9d70a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,11 @@ FROM docker.io/library/golang:1.22-alpine3.20 AS build-env ARG GOPROXY -ENV GOPROXY ${GOPROXY:-direct} +ENV GOPROXY=${GOPROXY:-direct} ARG GITEA_VERSION ARG TAGS="sqlite sqlite_unlock_notify" -ENV TAGS "bindata timetzdata $TAGS" +ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS # Build deps @@ -72,8 +72,8 @@ RUN addgroup \ git && \ echo "git:*" | chpasswd -e -ENV USER git -ENV GITEA_CUSTOM /data/gitea +ENV USER=git +ENV GITEA_CUSTOM=/data/gitea VOLUME ["/data"] diff --git a/Dockerfile.rootless b/Dockerfile.rootless index b1d2368252c9a..736cea5d055a0 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -2,11 +2,11 @@ FROM docker.io/library/golang:1.22-alpine3.20 AS build-env ARG GOPROXY -ENV GOPROXY ${GOPROXY:-direct} +ENV GOPROXY=${GOPROXY:-direct} ARG GITEA_VERSION ARG TAGS="sqlite sqlite_unlock_notify" -ENV TAGS "bindata timetzdata $TAGS" +ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS #Build deps @@ -75,14 +75,14 @@ COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_au # git:git USER 1000:1000 -ENV GITEA_WORK_DIR /var/lib/gitea -ENV GITEA_CUSTOM /var/lib/gitea/custom -ENV GITEA_TEMP /tmp/gitea -ENV TMPDIR /tmp/gitea +ENV GITEA_WORK_DIR=/var/lib/gitea +ENV GITEA_CUSTOM=/var/lib/gitea/custom +ENV GITEA_TEMP=/tmp/gitea +ENV TMPDIR=/tmp/gitea # TODO add to docs the ability to define the ini to load (useful to test and revert a config) -ENV GITEA_APP_INI /etc/gitea/app.ini -ENV HOME "/var/lib/gitea/git" +ENV GITEA_APP_INI=/etc/gitea/app.ini +ENV HOME="/var/lib/gitea/git" VOLUME ["/var/lib/gitea", "/etc/gitea"] WORKDIR /var/lib/gitea diff --git a/README.md b/README.md index fd96f9efbd258..c280c832ac7a3 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,8 @@ [![](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea "Help Contribute to Open Source") [![](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea "Become a backer/sponsor of gitea") [![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT "License: MIT") -[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/go-gitea/gitea) +[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=green)](https://gitpod.io/#https://github.com/go-gitea/gitea) [![](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea "Crowdin") -[![](https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main)](https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main "TODOs") [View this document in Chinese](./README_ZH.md) diff --git a/README_ZH.md b/README_ZH.md index 7aa7900a47f4a..a2e36dc22f18c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -8,9 +8,8 @@ [![](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea "Help Contribute to Open Source") [![](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea "Become a backer/sponsor of gitea") [![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT "License: MIT") -[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/go-gitea/gitea) +[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=green)](https://gitpod.io/#https://github.com/go-gitea/gitea) [![](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea "Crowdin") -[![](https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main)](https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main "TODOs") [View this document in English](./README.md) diff --git a/go.mod b/go.mod index ed9d806a65a0f..281604e26a797 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,7 @@ require ( github.com/google/go-github/v61 v61.0.0 github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 github.com/google/uuid v1.6.0 - github.com/gorilla/feeds v1.1.2 + github.com/gorilla/feeds v1.2.0 github.com/gorilla/sessions v1.2.2 github.com/h2non/gock v1.2.0 github.com/hashicorp/go-version v1.6.0 @@ -309,8 +309,6 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142 replace github.com/nektos/act => gitea.com/gitea/act v0.259.1 -replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 - // TODO: This could be removed after https://github.com/mholt/archiver/pull/396 merged replace github.com/mholt/archiver/v3 => github.com/anchore/archiver/v3 v3.5.2 diff --git a/go.sum b/go.sum index 11deacf91684c..9bb91bb4bcb2e 100644 --- a/go.sum +++ b/go.sum @@ -426,6 +426,8 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= +github.com/gorilla/feeds v1.2.0 h1:O6pBiXJ5JHhPvqy53NsjKOThq+dNFm8+DFrxBEdzSCc= +github.com/gorilla/feeds v1.2.0/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= @@ -811,8 +813,6 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw= github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk= -github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 h1:3seWKGVhGoc66Ht5QlhQsr4xT2caDnFegsnh2NqvENU= -github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js= github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= diff --git a/models/repo/repo.go b/models/repo/repo.go index f02c55fc895a9..189c4aba6cad7 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -362,7 +362,7 @@ func (repo *Repository) LoadUnits(ctx context.Context) (err error) { if log.IsTrace() { unitTypeStrings := make([]string, len(repo.Units)) for i, unit := range repo.Units { - unitTypeStrings[i] = unit.Type.String() + unitTypeStrings[i] = unit.Type.LogString() } log.Trace("repo.Units, ID=%d, Types: [%s]", repo.ID, strings.Join(unitTypeStrings, ", ")) } diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index fd5baa948861c..cb52c2c9e2058 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -33,7 +33,7 @@ func IsErrUnitTypeNotExist(err error) bool { } func (err ErrUnitTypeNotExist) Error() string { - return fmt.Sprintf("Unit type does not exist: %s", err.UT.String()) + return fmt.Sprintf("Unit type does not exist: %s", err.UT.LogString()) } func (err ErrUnitTypeNotExist) Unwrap() error { diff --git a/models/unit/unit.go b/models/unit/unit.go index 8eedcbd347378..3b62e5f982267 100644 --- a/models/unit/unit.go +++ b/models/unit/unit.go @@ -33,39 +33,18 @@ const ( TypeActions // 10 Actions ) -// Value returns integer value for unit type +// Value returns integer value for unit type (used by template) func (u Type) Value() int { return int(u) } -func (u Type) String() string { - switch u { - case TypeCode: - return "TypeCode" - case TypeIssues: - return "TypeIssues" - case TypePullRequests: - return "TypePullRequests" - case TypeReleases: - return "TypeReleases" - case TypeWiki: - return "TypeWiki" - case TypeExternalWiki: - return "TypeExternalWiki" - case TypeExternalTracker: - return "TypeExternalTracker" - case TypeProjects: - return "TypeProjects" - case TypePackages: - return "TypePackages" - case TypeActions: - return "TypeActions" - } - return fmt.Sprintf("Unknown Type %d", u) -} - func (u Type) LogString() string { - return fmt.Sprintf("", u, u.String()) + unit, ok := Units[u] + unitName := "unknown" + if ok { + unitName = unit.NameKey + } + return fmt.Sprintf("", u, unitName) } var ( @@ -133,7 +112,7 @@ func validateDefaultRepoUnits(defaultUnits, settingDefaultUnits []Type) []Type { units = make([]Type, 0, len(settingDefaultUnits)) for _, settingUnit := range settingDefaultUnits { if !settingUnit.CanBeDefault() { - log.Warn("Not allowed as default unit: %s", settingUnit.String()) + log.Warn("Not allowed as default unit: %s", settingUnit.LogString()) continue } units = append(units, settingUnit) diff --git a/modules/markup/html.go b/modules/markup/html.go index 565bc175b7eb0..c312d3cba0e50 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -144,20 +144,6 @@ func CustomLinkURLSchemes(schemes []string) { common.LinkRegex, _ = xurls.StrictMatchingScheme(strings.Join(withAuth, "|")) } -// IsSameDomain checks if given url string has the same hostname as current Gitea instance -func IsSameDomain(s string) bool { - if strings.HasPrefix(s, "/") { - return true - } - if uapp, err := url.Parse(setting.AppURL); err == nil { - if u, err := url.Parse(s); err == nil { - return u.Host == uapp.Host - } - return false - } - return false -} - type postProcessError struct { context string err error @@ -429,7 +415,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod // We ignore code and pre. switch node.Type { case html.TextNode: - textNode(ctx, procs, node) + processTextNodes(ctx, procs, node) case html.ElementNode: if node.Data == "img" { next := node.NextSibling @@ -465,15 +451,16 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node) *html.Nod for n := node.FirstChild; n != nil; { n = visitNode(ctx, procs, n) } + default: } return node.NextSibling } -// textNode runs the passed node through various processors, in order to handle +// processTextNodes runs the passed node through various processors, in order to handle // all kinds of special links handled by the post-processing. -func textNode(ctx *RenderContext, procs []processor, node *html.Node) { - for _, processor := range procs { - processor(ctx, node) +func processTextNodes(ctx *RenderContext, procs []processor, node *html.Node) { + for _, p := range procs { + p(ctx, node) } } @@ -761,10 +748,10 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) { if image { link = strings.ReplaceAll(link, " ", "+") } else { - link = strings.ReplaceAll(link, " ", "-") + link = strings.ReplaceAll(link, " ", "-") // FIXME: it should support dashes in the link, eg: "the-dash-support.-" } if !strings.Contains(link, "/") { - link = url.PathEscape(link) + link = url.PathEscape(link) // FIXME: it doesn't seem right and it might cause double-escaping } } if image { @@ -796,28 +783,7 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) { childNode.Attr = childNode.Attr[:2] } } else { - if !absoluteLink { - var base string - if ctx.IsWiki { - switch ext { - case "": - // no file extension, create a regular wiki link - base = ctx.Links.WikiLink() - default: - // we have a file extension: - // return a regular wiki link if it's a renderable file (extension), - // raw link otherwise - if Type(link) != "" { - base = ctx.Links.WikiLink() - } else { - base = ctx.Links.WikiRawLink() - } - } - } else { - base = ctx.Links.SrcLink() - } - link = util.URLJoin(base, link) - } + link, _ = ResolveLink(ctx, link, "") childNode.Type = html.TextNode childNode.Data = name } @@ -939,14 +905,11 @@ func issueIndexPatternProcessor(ctx *RenderContext, node *html.Node) { // Path determines the type of link that will be rendered. It's unknown at this point whether // the linked item is actually a PR or an issue. Luckily it's of no real consequence because // Gitea will redirect on click as appropriate. - path := "issues" - if ref.IsPull { - path = "pulls" - } + issuePath := util.Iif(ref.IsPull, "pulls", "issues") if ref.Owner == "" { - link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], path, ref.Issue), reftext, "ref-issue") + link = createLink(util.URLJoin(ctx.Links.Prefix(), ctx.Metas["user"], ctx.Metas["repo"], issuePath, ref.Issue), reftext, "ref-issue") } else { - link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, path, ref.Issue), reftext, "ref-issue") + link = createLink(util.URLJoin(ctx.Links.Prefix(), ref.Owner, ref.Name, issuePath, ref.Issue), reftext, "ref-issue") } } @@ -1207,7 +1170,7 @@ func hashCurrentPatternProcessor(ctx *RenderContext, node *html.Node) { return } ctx.AddCancel(func() { - closer.Close() + _ = closer.Close() ctx.GitRepo = nil }) } diff --git a/modules/markup/html_link.go b/modules/markup/html_link.go new file mode 100644 index 0000000000000..a41b87e9fa83d --- /dev/null +++ b/modules/markup/html_link.go @@ -0,0 +1,35 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package markup + +import ( + "path" + + "code.gitea.io/gitea/modules/util" +) + +func ResolveLink(ctx *RenderContext, link, userContentAnchorPrefix string) (result string, resolved bool) { + isAnchorFragment := link != "" && link[0] == '#' + if !isAnchorFragment && !IsFullURLString(link) { + linkBase := ctx.Links.Base + if ctx.IsWiki { + if ext := path.Ext(link); ext == "" || ext == ".-" { + linkBase = ctx.Links.WikiLink() // the link is for a wiki page + } else if DetectMarkupTypeByFileName(link) != "" { + linkBase = ctx.Links.WikiLink() // the link is renderable as a wiki page + } else { + linkBase = ctx.Links.WikiRawLink() // otherwise, use a raw link instead to view&download medias + } + } else if ctx.Links.BranchPath != "" || ctx.Links.TreePath != "" { + // if there is no BranchPath, then the link will be something like "/owner/repo/src/{the-file-path}" + // and then this link will be handled by the "legacy-ref" code and be redirected to the default branch like "/owner/repo/src/branch/main/{the-file-path}" + linkBase = ctx.Links.SrcLink() + } + link, resolved = util.URLJoin(linkBase, link), true + } + if isAnchorFragment && userContentAnchorPrefix != "" { + link, resolved = userContentAnchorPrefix+link[1:], true + } + return link, resolved +} diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index df3c2609ef4a3..399488912eefe 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -144,17 +144,6 @@ func TestRender_CrossReferences(t *testing.T) { `

0123456789/foo.txt (L2-L3)

`) } -func TestMisc_IsSameDomain(t *testing.T) { - setting.AppURL = markup.TestAppURL - - sha := "b6dd6210eaebc915fd5be5579c58cce4da2e2579" - commit := util.URLJoin(markup.TestRepoURL, "commit", sha) - - assert.True(t, markup.IsSameDomain(commit)) - assert.False(t, markup.IsSameDomain("http://google.com/ncr")) - assert.False(t, markup.IsSameDomain("favicon.ico")) -} - func TestRender_links(t *testing.T) { setting.AppURL = markup.TestAppURL @@ -455,6 +444,10 @@ func TestRender_ShortLinks(t *testing.T) { "[[Link]]", `

Link

`, `

Link

`) + test( + "[[Link.-]]", + `

Link.-

`, + `

Link.-

`) test( "[[Link.jpg]]", `

Link.jpg

`, diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 8c41ec12e3fb1..1a88d5d44a940 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -551,6 +551,10 @@ func TestMathBlock(t *testing.T) { "$$a$$", `
a
` + nl, }, + { + "$a$ ($b$) [$c$] {$d$}", + `

a (b) [$c$] {$d$}

` + nl, + }, } for _, test := range testcases { @@ -635,7 +639,7 @@ mail@domain.com https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -691,7 +695,7 @@ space

https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -749,7 +753,7 @@ space

https://example.com/file.bin
local link
remote link
-local link
+local link
remote link
local image
local image
@@ -866,7 +870,7 @@ space

Expected: `

space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link
@@ -984,7 +988,7 @@ space

for i, c := range cases { result, err := markdown.RenderString(&markup.RenderContext{Ctx: context.Background(), Links: c.Links, IsWiki: c.IsWiki}, input) assert.NoError(t, err, "Unexpected error in testcase: %v", i) - assert.Equal(t, template.HTML(c.Expected), result, "Unexpected result in testcase %v", i) + assert.Equal(t, c.Expected, string(result), "Unexpected result in testcase %v", i) } } diff --git a/modules/markup/markdown/math/inline_parser.go b/modules/markup/markdown/math/inline_parser.go index 862234e69bb74..614cf329af86e 100644 --- a/modules/markup/markdown/math/inline_parser.go +++ b/modules/markup/markdown/math/inline_parser.go @@ -45,6 +45,10 @@ func isPunctuation(b byte) bool { return b == '.' || b == '!' || b == '?' || b == ',' || b == ';' || b == ':' } +func isBracket(b byte) bool { + return b == ')' +} + func isAlphanumeric(b byte) bool { return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '0' && b <= '9') } @@ -84,7 +88,7 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser. break } suceedingCharacter := line[pos] - if !isPunctuation(suceedingCharacter) && !(suceedingCharacter == ' ') { + if !isPunctuation(suceedingCharacter) && !(suceedingCharacter == ' ') && !isBracket(suceedingCharacter) { return nil } if line[ender-1] != '\\' { diff --git a/modules/markup/markdown/transform_link.go b/modules/markup/markdown/transform_link.go index 527a5dfc44659..38fbf693ab837 100644 --- a/modules/markup/markdown/transform_link.go +++ b/modules/markup/markdown/transform_link.go @@ -4,38 +4,13 @@ package markdown import ( - "path/filepath" - "code.gitea.io/gitea/modules/markup" - giteautil "code.gitea.io/gitea/modules/util" "github.com/yuin/goldmark/ast" ) func (g *ASTTransformer) transformLink(ctx *markup.RenderContext, v *ast.Link) { - // Links need their href to munged to be a real value - link := v.Destination - isAnchorFragment := len(link) > 0 && link[0] == '#' - if !isAnchorFragment && !markup.IsFullURLBytes(link) { - base := ctx.Links.Base - if ctx.IsWiki { - if filepath.Ext(string(link)) == "" { - // This link doesn't have a file extension - assume a regular wiki link - base = ctx.Links.WikiLink() - } else if markup.Type(string(link)) != "" { - // If it's a file type we can render, use a regular wiki link - base = ctx.Links.WikiLink() - } else { - // Otherwise, use a raw link instead - base = ctx.Links.WikiRawLink() - } - } else if ctx.Links.HasBranchInfo() { - base = ctx.Links.SrcLink() - } - link = []byte(giteautil.URLJoin(base, string(link))) - } - if isAnchorFragment { - link = []byte("#user-content-" + string(link)[1:]) + if link, resolved := markup.ResolveLink(ctx, string(v.Destination), "#user-content-"); resolved { + v.Destination = []byte(link) } - v.Destination = link } diff --git a/modules/markup/renderer.go b/modules/markup/renderer.go index 5eb568cb1f0dd..18bdfc9761126 100644 --- a/modules/markup/renderer.go +++ b/modules/markup/renderer.go @@ -372,22 +372,14 @@ func renderFile(ctx *RenderContext, input io.Reader, output io.Writer) error { return ErrUnsupportedRenderExtension{extension} } -// Type returns if markup format via the filename -func Type(filename string) string { +// DetectMarkupTypeByFileName returns the possible markup format type via the filename +func DetectMarkupTypeByFileName(filename string) string { if parser := GetRendererByFileName(filename); parser != nil { return parser.Name() } return "" } -// IsMarkupFile reports whether file is a markup type file -func IsMarkupFile(name, markup string) bool { - if parser := GetRendererByFileName(name); parser != nil { - return parser.Name() == markup - } - return false -} - func PreviewableExtensions() []string { extensions := make([]string, 0, len(extRenderers)) for extension := range extRenderers { diff --git a/modules/structs/org_team.go b/modules/structs/org_team.go index 78dc4abaefd32..f8899b236bf4f 100644 --- a/modules/structs/org_team.go +++ b/modules/structs/org_team.go @@ -24,7 +24,7 @@ type Team struct { // CreateTeamOption options for creating a team type CreateTeamOption struct { // required: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` + Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"` IncludesAllRepositories bool `json:"includes_all_repositories"` // enum: read,write,admin @@ -40,7 +40,7 @@ type CreateTeamOption struct { // EditTeamOption options for editing a team type EditTeamOption struct { // required: true - Name string `json:"name" binding:"AlphaDashDot;MaxSize(30)"` + Name string `json:"name" binding:"AlphaDashDot;MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(255)"` IncludesAllRepositories *bool `json:"includes_all_repositories"` // enum: read,write,admin diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 330cbf8908b15..5f73e6b278cdb 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -36,16 +36,16 @@ func NewFuncMap() template.FuncMap { // ----------------------------------------------------------------- // html/template related functions "dict": dict, // it's lowercase because this name has been widely used. Our other functions should have uppercase names. - "Iif": Iif, - "Eval": Eval, - "SafeHTML": SafeHTML, + "Iif": iif, + "Eval": evalTokens, + "SafeHTML": safeHTML, "HTMLFormat": HTMLFormat, - "HTMLEscape": HTMLEscape, - "QueryEscape": QueryEscape, - "JSEscape": JSEscapeSafe, + "HTMLEscape": htmlEscape, + "QueryEscape": queryEscape, + "JSEscape": jsEscapeSafe, "SanitizeHTML": SanitizeHTML, "URLJoin": util.URLJoin, - "DotEscape": DotEscape, + "DotEscape": dotEscape, "PathEscape": url.PathEscape, "PathEscapeSegments": util.PathEscapeSegments, @@ -59,9 +59,9 @@ func NewFuncMap() template.FuncMap { // svg / avatar / icon / color "svg": svg.RenderHTML, "EntryIcon": base.EntryIcon, - "MigrationIcon": MigrationIcon, - "ActionIcon": ActionIcon, - "SortArrow": SortArrow, + "MigrationIcon": migrationIcon, + "ActionIcon": actionIcon, + "SortArrow": sortArrow, "ContrastColor": util.ContrastColor, // ----------------------------------------------------------------- @@ -139,7 +139,7 @@ func NewFuncMap() template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, - "UserThemeName": UserThemeName, + "UserThemeName": userThemeName, "NotificationSettings": func() map[string]any { return map[string]any{ "MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond), @@ -155,28 +155,28 @@ func NewFuncMap() template.FuncMap { // ----------------------------------------------------------------- // render "RenderCommitMessage": RenderCommitMessage, - "RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject, + "RenderCommitMessageLinkSubject": renderCommitMessageLinkSubject, - "RenderCommitBody": RenderCommitBody, - "RenderCodeBlock": RenderCodeBlock, - "RenderIssueTitle": RenderIssueTitle, - "RenderEmoji": RenderEmoji, - "ReactionToEmoji": ReactionToEmoji, + "RenderCommitBody": renderCommitBody, + "RenderCodeBlock": renderCodeBlock, + "RenderIssueTitle": renderIssueTitle, + "RenderEmoji": renderEmoji, + "ReactionToEmoji": reactionToEmoji, "RenderMarkdownToHtml": RenderMarkdownToHtml, - "RenderLabel": RenderLabel, + "RenderLabel": renderLabel, "RenderLabels": RenderLabels, // ----------------------------------------------------------------- // misc "ShortSha": base.ShortSha, "ActionContent2Commits": ActionContent2Commits, - "IsMultilineCommitMessage": IsMultilineCommitMessage, + "IsMultilineCommitMessage": isMultilineCommitMessage, "CommentMustAsDiff": gitdiff.CommentMustAsDiff, "MirrorRemoteAddress": mirrorRemoteAddress, - "FilenameIsImage": FilenameIsImage, - "TabSizeClass": TabSizeClass, + "FilenameIsImage": filenameIsImage, + "TabSizeClass": tabSizeClass, } } @@ -197,8 +197,8 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML { return template.HTML(fmt.Sprintf(s, args...)) } -// SafeHTML render raw as HTML -func SafeHTML(s any) template.HTML { +// safeHTML render raw as HTML +func safeHTML(s any) template.HTML { switch v := s.(type) { case string: return template.HTML(v) @@ -213,7 +213,7 @@ func SanitizeHTML(s string) template.HTML { return template.HTML(markup.Sanitize(s)) } -func HTMLEscape(s any) template.HTML { +func htmlEscape(s any) template.HTML { switch v := s.(type) { case string: return template.HTML(html.EscapeString(v)) @@ -223,22 +223,22 @@ func HTMLEscape(s any) template.HTML { panic(fmt.Sprintf("unexpected type %T", s)) } -func JSEscapeSafe(s string) template.HTML { +func jsEscapeSafe(s string) template.HTML { return template.HTML(template.JSEscapeString(s)) } -func QueryEscape(s string) template.URL { +func queryEscape(s string) template.URL { return template.URL(url.QueryEscape(s)) } -// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls -func DotEscape(raw string) string { +// dotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent auto-linkers from detecting these as urls +func dotEscape(raw string) string { return strings.ReplaceAll(raw, ".", "\u200d.\u200d") } -// Iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version, -// and it could be simply used as "{{Iif expr trueVal}}" (omit the falseVal). -func Iif(condition any, vals ...any) any { +// iif is an "inline-if", similar util.Iif[T] but templates need the non-generic version, +// and it could be simply used as "{{iif expr trueVal}}" (omit the falseVal). +func iif(condition any, vals ...any) any { if isTemplateTruthy(condition) { return vals[0] } else if len(vals) > 1 { @@ -273,19 +273,19 @@ func isTemplateTruthy(v any) bool { } } -// Eval the expression and return the result, see the comment of eval.Expr for details. +// evalTokens evaluates the expression by tokens and returns the result, see the comment of eval.Expr for details. // To use this helper function in templates, pass each token as a separate parameter. // // {{ $int64 := Eval $var "+" 1 }} // {{ $float64 := Eval $var "+" 1.0 }} // // Golang's template supports comparable int types, so the int64 result can be used in later statements like {{if lt $int64 10}} -func Eval(tokens ...any) (any, error) { +func evalTokens(tokens ...any) (any, error) { n, err := eval.Expr(tokens...) return n.Value, err } -func UserThemeName(user *user_model.User) string { +func userThemeName(user *user_model.User) string { if user == nil || user.Theme == "" { return setting.UI.DefaultTheme } diff --git a/modules/templates/helper_test.go b/modules/templates/helper_test.go index ea5da7be80845..b9fabb7016460 100644 --- a/modules/templates/helper_test.go +++ b/modules/templates/helper_test.go @@ -58,7 +58,7 @@ func TestSubjectBodySeparator(t *testing.T) { } func TestJSEscapeSafe(t *testing.T) { - assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, JSEscapeSafe(`&<>'"`)) + assert.EqualValues(t, `\u0026\u003C\u003E\'\"`, jsEscapeSafe(`&<>'"`)) } func TestHTMLFormat(t *testing.T) { @@ -71,7 +71,7 @@ func TestSanitizeHTML(t *testing.T) { func TestTemplateTruthy(t *testing.T) { tmpl := template.New("test") - tmpl.Funcs(template.FuncMap{"Iif": Iif}) + tmpl.Funcs(template.FuncMap{"Iif": iif}) template.Must(tmpl.Parse(`{{if .Value}}true{{else}}false{{end}}:{{Iif .Value "true" "false"}}`)) cases := []any{ diff --git a/modules/templates/mailer.go b/modules/templates/mailer.go index 7c97e1ea89d9f..ace81bf4a500f 100644 --- a/modules/templates/mailer.go +++ b/modules/templates/mailer.go @@ -22,7 +22,7 @@ var mailSubjectSplit = regexp.MustCompile(`(?m)^-{3,}\s*$`) func mailSubjectTextFuncMap() texttmpl.FuncMap { return texttmpl.FuncMap{ "dict": dict, - "Eval": Eval, + "Eval": evalTokens, "EllipsisString": base.EllipsisString, "AppName": func() string { diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go index 774385483b4c6..d645fa013e81e 100644 --- a/modules/templates/util_misc.go +++ b/modules/templates/util_misc.go @@ -24,7 +24,7 @@ import ( "github.com/editorconfig/editorconfig-core-go/v2" ) -func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML { +func sortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML { // if needed if len(normSort) == 0 || len(urlSort) == 0 { return "" @@ -50,8 +50,8 @@ func SortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML return "" } -// IsMultilineCommitMessage checks to see if a commit message contains multiple lines. -func IsMultilineCommitMessage(msg string) bool { +// isMultilineCommitMessage checks to see if a commit message contains multiple lines. +func isMultilineCommitMessage(msg string) bool { return strings.Count(strings.TrimSpace(msg), "\n") >= 1 } @@ -69,8 +69,8 @@ type Actioner interface { GetIssueInfos() []string } -// ActionIcon accepts an action operation type and returns an icon class name. -func ActionIcon(opType activities_model.ActionType) string { +// actionIcon accepts an action operation type and returns an icon class name. +func actionIcon(opType activities_model.ActionType) string { switch opType { case activities_model.ActionCreateRepo, activities_model.ActionTransferRepo, activities_model.ActionRenameRepo: return "repo" @@ -126,8 +126,8 @@ func ActionContent2Commits(act Actioner) *repository.PushCommits { return push } -// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from -func MigrationIcon(hostname string) string { +// migrationIcon returns a SVG name matching the service an issue/comment was migrated from +func migrationIcon(hostname string) string { switch hostname { case "github.com": return "octicon-mark-github" @@ -177,12 +177,12 @@ func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteNa return ret } -func FilenameIsImage(filename string) bool { +func filenameIsImage(filename string) bool { mimeType := mime.TypeByExtension(filepath.Ext(filename)) return strings.HasPrefix(mimeType, "image/") } -func TabSizeClass(ec *editorconfig.Editorconfig, filename string) string { +func tabSizeClass(ec *editorconfig.Editorconfig, filename string) string { if ec != nil { def, err := ec.GetDefinitionForFilename(filename) if err == nil && def.TabWidth >= 1 && def.TabWidth <= 16 { diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index b15de6521df68..6eee007f34683 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -41,12 +41,12 @@ func RenderCommitMessage(ctx context.Context, msg string, metas map[string]strin if len(msgLines) == 0 { return template.HTML("") } - return RenderCodeBlock(template.HTML(msgLines[0])) + return renderCodeBlock(template.HTML(msgLines[0])) } -// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to +// renderCommitMessageLinkSubject renders commit message as a XSS-safe link to // the provided default url, handling for special links without email to links. -func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML { +func renderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML { msgLine := strings.TrimLeftFunc(msg, unicode.IsSpace) lineEnd := strings.IndexByte(msgLine, '\n') if lineEnd > 0 { @@ -68,11 +68,11 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, log.Error("RenderCommitMessageSubject: %v", err) return template.HTML("") } - return RenderCodeBlock(template.HTML(renderedMessage)) + return renderCodeBlock(template.HTML(renderedMessage)) } -// RenderCommitBody extracts the body of a commit message without its title. -func RenderCommitBody(ctx context.Context, msg string, metas map[string]string) template.HTML { +// renderCommitBody extracts the body of a commit message without its title. +func renderCommitBody(ctx context.Context, msg string, metas map[string]string) template.HTML { msgLine := strings.TrimSpace(msg) lineEnd := strings.IndexByte(msgLine, '\n') if lineEnd > 0 { @@ -99,14 +99,14 @@ func RenderCommitBody(ctx context.Context, msg string, metas map[string]string) // Match text that is between back ticks. var codeMatcher = regexp.MustCompile("`([^`]+)`") -// RenderCodeBlock renders "`…`" as highlighted "" block, intended for issue and PR titles -func RenderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML { +// renderCodeBlock renders "`…`" as highlighted "" block, intended for issue and PR titles +func renderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML { htmlWithCodeTags := codeMatcher.ReplaceAllString(string(htmlEscapedTextToRender), `$1`) // replace with HTML tags return template.HTML(htmlWithCodeTags) } -// RenderIssueTitle renders issue/pull title with defined post processors -func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) template.HTML { +// renderIssueTitle renders issue/pull title with defined post processors +func renderIssueTitle(ctx context.Context, text string, metas map[string]string) template.HTML { renderedText, err := markup.RenderIssueTitle(&markup.RenderContext{ Ctx: ctx, Metas: metas, @@ -118,9 +118,9 @@ func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) return template.HTML(renderedText) } -// RenderLabel renders a label +// renderLabel renders a label // locale is needed due to an import cycle with our context providing the `Tr` function -func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { +func renderLabel(ctx context.Context, locale translation.Locale, label *issues_model.Label) template.HTML { var extraCSSClasses string textColor := util.ContrastColor(label.Color) labelScope := label.ExclusiveScope() @@ -134,12 +134,12 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m if labelScope == "" { // Regular label return HTMLFormat(`
%s
`, - extraCSSClasses, textColor, label.Color, descriptionText, RenderEmoji(ctx, label.Name)) + extraCSSClasses, textColor, label.Color, descriptionText, renderEmoji(ctx, label.Name)) } // Scoped label - scopeHTML := RenderEmoji(ctx, labelScope) - itemHTML := RenderEmoji(ctx, label.Name[len(labelScope)+1:]) + scopeHTML := renderEmoji(ctx, labelScope) + itemHTML := renderEmoji(ctx, label.Name[len(labelScope)+1:]) // Make scope and item background colors slightly darker and lighter respectively. // More contrast needed with higher luminance, empirically tweaked. @@ -176,8 +176,8 @@ func RenderLabel(ctx context.Context, locale translation.Locale, label *issues_m textColor, itemColor, itemHTML) } -// RenderEmoji renders html text with emoji post processors -func RenderEmoji(ctx context.Context, text string) template.HTML { +// renderEmoji renders html text with emoji post processors +func renderEmoji(ctx context.Context, text string) template.HTML { renderedText, err := markup.RenderEmoji(&markup.RenderContext{Ctx: ctx}, template.HTMLEscapeString(text)) if err != nil { @@ -187,8 +187,8 @@ func RenderEmoji(ctx context.Context, text string) template.HTML { return template.HTML(renderedText) } -// ReactionToEmoji renders emoji for use in reactions -func ReactionToEmoji(reaction string) template.HTML { +// reactionToEmoji renders emoji for use in reactions +func reactionToEmoji(reaction string) template.HTML { val := emoji.FromCode(reaction) if val != nil { return template.HTML(val.Emoji) @@ -220,7 +220,7 @@ func RenderLabels(ctx context.Context, locale translation.Locale, labels []*issu if label == nil { continue } - htmlCode += fmt.Sprintf(`%s`, baseLink, label.ID, RenderLabel(ctx, locale, label)) + htmlCode += fmt.Sprintf(`%s`, baseLink, label.ID, renderLabel(ctx, locale, label)) } htmlCode += "" return template.HTML(htmlCode) diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go index f493b899e393c..ba47c34efc193 100644 --- a/modules/templates/util_render_test.go +++ b/modules/templates/util_render_test.go @@ -103,7 +103,7 @@ func TestRenderCommitBody(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equalf(t, tt.want, RenderCommitBody(tt.args.ctx, tt.args.msg, tt.args.metas), "RenderCommitBody(%v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.metas) + assert.Equalf(t, tt.want, renderCommitBody(tt.args.ctx, tt.args.msg, tt.args.metas), "RenderCommitBody(%v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.metas) }) } @@ -127,7 +127,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit #123 space` - assert.EqualValues(t, expected, RenderCommitBody(context.Background(), testInput(), testMetas)) + assert.EqualValues(t, expected, renderCommitBody(context.Background(), testInput(), testMetas)) } func TestRenderCommitMessage(t *testing.T) { @@ -139,7 +139,7 @@ func TestRenderCommitMessage(t *testing.T) { func TestRenderCommitMessageLinkSubject(t *testing.T) { expected := `space @mention-user` - assert.EqualValues(t, expected, RenderCommitMessageLinkSubject(context.Background(), testInput(), "https://example.com/link", testMetas)) + assert.EqualValues(t, expected, renderCommitMessageLinkSubject(context.Background(), testInput(), "https://example.com/link", testMetas)) } func TestRenderIssueTitle(t *testing.T) { @@ -165,7 +165,7 @@ mail@domain.com space ` expected = strings.ReplaceAll(expected, "", " ") - assert.EqualValues(t, expected, RenderIssueTitle(context.Background(), testInput(), testMetas)) + assert.EqualValues(t, expected, renderIssueTitle(context.Background(), testInput(), testMetas)) } func TestRenderMarkdownToHtml(t *testing.T) { @@ -174,7 +174,7 @@ func TestRenderMarkdownToHtml(t *testing.T) { https://example.com/file.bin local link remote link -local link +local link remote link local image remote image @@ -190,7 +190,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit #123 space

` - assert.EqualValues(t, expected, RenderMarkdownToHtml(context.Background(), testInput())) + assert.Equal(t, expected, string(RenderMarkdownToHtml(context.Background(), testInput()))) } func TestRenderLabels(t *testing.T) { diff --git a/modules/web/route.go b/modules/web/route.go index 805fcb4411529..b02f66802ee50 100644 --- a/modules/web/route.go +++ b/modules/web/route.go @@ -5,8 +5,10 @@ package web import ( "net/http" + "net/url" "strings" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web/middleware" "gitea.com/go-chi/binding" @@ -34,30 +36,30 @@ func GetForm(dataStore middleware.ContextDataStore) any { return dataStore.GetData()["__form"] } -// Route defines a route based on chi's router -type Route struct { - R chi.Router +// Router defines a route based on chi's router +type Router struct { + chiRouter chi.Router curGroupPrefix string curMiddlewares []any } -// NewRoute creates a new route -func NewRoute() *Route { +// NewRouter creates a new route +func NewRouter() *Router { r := chi.NewRouter() - return &Route{R: r} + return &Router{chiRouter: r} } // Use supports two middlewares -func (r *Route) Use(middlewares ...any) { +func (r *Router) Use(middlewares ...any) { for _, m := range middlewares { if m != nil { - r.R.Use(toHandlerProvider(m)) + r.chiRouter.Use(toHandlerProvider(m)) } } } // Group mounts a sub-Router along a `pattern` string. -func (r *Route) Group(pattern string, fn func(), middlewares ...any) { +func (r *Router) Group(pattern string, fn func(), middlewares ...any) { previousGroupPrefix := r.curGroupPrefix previousMiddlewares := r.curMiddlewares r.curGroupPrefix += pattern @@ -69,7 +71,7 @@ func (r *Route) Group(pattern string, fn func(), middlewares ...any) { r.curMiddlewares = previousMiddlewares } -func (r *Route) getPattern(pattern string) string { +func (r *Router) getPattern(pattern string) string { newPattern := r.curGroupPrefix + pattern if !strings.HasPrefix(newPattern, "/") { newPattern = "/" + newPattern @@ -80,7 +82,7 @@ func (r *Route) getPattern(pattern string) string { return strings.TrimSuffix(newPattern, "/") } -func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Handler, http.HandlerFunc) { +func (r *Router) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Handler, http.HandlerFunc) { handlerProviders := make([]func(http.Handler) http.Handler, 0, len(r.curMiddlewares)+len(h)+1) for _, m := range r.curMiddlewares { if m != nil { @@ -94,7 +96,7 @@ func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Han } middlewares := handlerProviders[:len(handlerProviders)-1] handlerFunc := handlerProviders[len(handlerProviders)-1](nil).ServeHTTP - mockPoint := RouteMockPoint(MockAfterMiddlewares) + mockPoint := RouterMockPoint(MockAfterMiddlewares) if mockPoint != nil { middlewares = append(middlewares, mockPoint) } @@ -103,79 +105,134 @@ func (r *Route) wrapMiddlewareAndHandler(h []any) ([]func(http.Handler) http.Han // Methods adds the same handlers for multiple http "methods" (separated by ","). // If any method is invalid, the lower level router will panic. -func (r *Route) Methods(methods, pattern string, h ...any) { +func (r *Router) Methods(methods, pattern string, h ...any) { middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h) fullPattern := r.getPattern(pattern) if strings.Contains(methods, ",") { methods := strings.Split(methods, ",") for _, method := range methods { - r.R.With(middlewares...).Method(strings.TrimSpace(method), fullPattern, handlerFunc) + r.chiRouter.With(middlewares...).Method(strings.TrimSpace(method), fullPattern, handlerFunc) } } else { - r.R.With(middlewares...).Method(methods, fullPattern, handlerFunc) + r.chiRouter.With(middlewares...).Method(methods, fullPattern, handlerFunc) } } -// Mount attaches another Route along ./pattern/* -func (r *Route) Mount(pattern string, subR *Route) { - subR.Use(r.curMiddlewares...) - r.R.Mount(r.getPattern(pattern), subR.R) +// Mount attaches another Router along ./pattern/* +func (r *Router) Mount(pattern string, subRouter *Router) { + subRouter.Use(r.curMiddlewares...) + r.chiRouter.Mount(r.getPattern(pattern), subRouter.chiRouter) } // Any delegate requests for all methods -func (r *Route) Any(pattern string, h ...any) { +func (r *Router) Any(pattern string, h ...any) { middlewares, handlerFunc := r.wrapMiddlewareAndHandler(h) - r.R.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc) + r.chiRouter.With(middlewares...).HandleFunc(r.getPattern(pattern), handlerFunc) } // Delete delegate delete method -func (r *Route) Delete(pattern string, h ...any) { +func (r *Router) Delete(pattern string, h ...any) { r.Methods("DELETE", pattern, h...) } // Get delegate get method -func (r *Route) Get(pattern string, h ...any) { +func (r *Router) Get(pattern string, h ...any) { r.Methods("GET", pattern, h...) } // Head delegate head method -func (r *Route) Head(pattern string, h ...any) { +func (r *Router) Head(pattern string, h ...any) { r.Methods("HEAD", pattern, h...) } // Post delegate post method -func (r *Route) Post(pattern string, h ...any) { +func (r *Router) Post(pattern string, h ...any) { r.Methods("POST", pattern, h...) } // Put delegate put method -func (r *Route) Put(pattern string, h ...any) { +func (r *Router) Put(pattern string, h ...any) { r.Methods("PUT", pattern, h...) } // Patch delegate patch method -func (r *Route) Patch(pattern string, h ...any) { +func (r *Router) Patch(pattern string, h ...any) { r.Methods("PATCH", pattern, h...) } // ServeHTTP implements http.Handler -func (r *Route) ServeHTTP(w http.ResponseWriter, req *http.Request) { - r.R.ServeHTTP(w, req) +func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { + r.normalizeRequestPath(w, req, r.chiRouter) } // NotFound defines a handler to respond whenever a route could not be found. -func (r *Route) NotFound(h http.HandlerFunc) { - r.R.NotFound(h) +func (r *Router) NotFound(h http.HandlerFunc) { + r.chiRouter.NotFound(h) +} + +func (r *Router) normalizeRequestPath(resp http.ResponseWriter, req *http.Request, next http.Handler) { + normalized := false + normalizedPath := req.URL.EscapedPath() + if normalizedPath == "" { + normalizedPath, normalized = "/", true + } else if normalizedPath != "/" { + normalized = strings.HasSuffix(normalizedPath, "/") + normalizedPath = strings.TrimRight(normalizedPath, "/") + } + removeRepeatedSlashes := strings.Contains(normalizedPath, "//") + normalized = normalized || removeRepeatedSlashes + + // the following code block is a slow-path for replacing all repeated slashes "//" to one single "/" + // if the path doesn't have repeated slashes, then no need to execute it + if removeRepeatedSlashes { + buf := &strings.Builder{} + for i := 0; i < len(normalizedPath); i++ { + if i == 0 || normalizedPath[i-1] != '/' || normalizedPath[i] != '/' { + buf.WriteByte(normalizedPath[i]) + } + } + normalizedPath = buf.String() + } + + // If the config tells Gitea to use a sub-url path directly without reverse proxy, + // then we need to remove the sub-url path from the request URL path. + // But "/v2" is special for OCI container registry, it should always be in the root of the site. + if setting.UseSubURLPath { + remainingPath, ok := strings.CutPrefix(normalizedPath, setting.AppSubURL+"/") + if ok { + normalizedPath = "/" + remainingPath + } else if normalizedPath == setting.AppSubURL { + normalizedPath = "/" + } else if !strings.HasPrefix(normalizedPath+"/", "/v2/") { + // do not respond to other requests, to simulate a real sub-path environment + http.Error(resp, "404 page not found, sub-path is: "+setting.AppSubURL, http.StatusNotFound) + return + } + normalized = true + } + + // if the path is normalized, then fill it back to the request + if normalized { + decodedPath, err := url.PathUnescape(normalizedPath) + if err != nil { + http.Error(resp, "400 Bad Request: unable to unescape path "+normalizedPath, http.StatusBadRequest) + return + } + req.URL.RawPath = normalizedPath + req.URL.Path = decodedPath + } + + next.ServeHTTP(resp, req) } // Combo delegates requests to Combo -func (r *Route) Combo(pattern string, h ...any) *Combo { +func (r *Router) Combo(pattern string, h ...any) *Combo { return &Combo{r, pattern, h} } // Combo represents a tiny group routes with same pattern type Combo struct { - r *Route + r *Router pattern string h []any } diff --git a/modules/web/route_test.go b/modules/web/route_test.go index cc0e26a12e3c4..6e4c309293b9e 100644 --- a/modules/web/route_test.go +++ b/modules/web/route_test.go @@ -10,6 +10,9 @@ import ( "strconv" "testing" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" + chi "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" ) @@ -19,7 +22,7 @@ func TestRoute1(t *testing.T) { recorder := httptest.NewRecorder() recorder.Body = buff - r := NewRoute() + r := NewRouter() r.Get("/{username}/{reponame}/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) { username := chi.URLParam(req, "username") assert.EqualValues(t, "gitea", username) @@ -42,7 +45,7 @@ func TestRoute2(t *testing.T) { hit := -1 - r := NewRoute() + r := NewRouter() r.Group("/{username}/{reponame}", func() { r.Group("", func() { r.Get("/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) { @@ -118,8 +121,8 @@ func TestRoute3(t *testing.T) { hit := -1 - m := NewRoute() - r := NewRoute() + m := NewRouter() + r := NewRouter() r.Mount("/api/v1", m) m.Group("/repos", func() { @@ -176,3 +179,44 @@ func TestRoute3(t *testing.T) { assert.EqualValues(t, http.StatusOK, recorder.Code) assert.EqualValues(t, 4, hit) } + +func TestRouteNormalizePath(t *testing.T) { + type paths struct { + EscapedPath, RawPath, Path string + } + testPath := func(reqPath string, expectedPaths paths) { + recorder := httptest.NewRecorder() + recorder.Body = bytes.NewBuffer(nil) + + actualPaths := paths{EscapedPath: "(none)", RawPath: "(none)", Path: "(none)"} + r := NewRouter() + r.Get("/*", func(resp http.ResponseWriter, req *http.Request) { + actualPaths.EscapedPath = req.URL.EscapedPath() + actualPaths.RawPath = req.URL.RawPath + actualPaths.Path = req.URL.Path + }) + + req, err := http.NewRequest("GET", reqPath, nil) + assert.NoError(t, err) + r.ServeHTTP(recorder, req) + assert.Equal(t, expectedPaths, actualPaths, "req path = %q", reqPath) + } + + // RawPath could be empty if the EscapedPath is the same as escape(Path) and it is already normalized + testPath("/", paths{EscapedPath: "/", RawPath: "", Path: "/"}) + testPath("//", paths{EscapedPath: "/", RawPath: "/", Path: "/"}) + testPath("/%2f", paths{EscapedPath: "/%2f", RawPath: "/%2f", Path: "//"}) + testPath("///a//b/", paths{EscapedPath: "/a/b", RawPath: "/a/b", Path: "/a/b"}) + + defer test.MockVariableValue(&setting.UseSubURLPath, true)() + defer test.MockVariableValue(&setting.AppSubURL, "/sub-path")() + testPath("/", paths{EscapedPath: "(none)", RawPath: "(none)", Path: "(none)"}) // 404 + testPath("/sub-path", paths{EscapedPath: "/", RawPath: "/", Path: "/"}) + testPath("/sub-path/", paths{EscapedPath: "/", RawPath: "/", Path: "/"}) + testPath("/sub-path//a/b///", paths{EscapedPath: "/a/b", RawPath: "/a/b", Path: "/a/b"}) + testPath("/sub-path/%2f/", paths{EscapedPath: "/%2f", RawPath: "/%2f", Path: "//"}) + // "/v2" is special for OCI container registry, it should always be in the root of the site + testPath("/v2", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"}) + testPath("/v2/", paths{EscapedPath: "/v2", RawPath: "/v2", Path: "/v2"}) + testPath("/v2/%2f", paths{EscapedPath: "/v2/%2f", RawPath: "/v2/%2f", Path: "/v2//"}) +} diff --git a/modules/web/routemock.go b/modules/web/routemock.go index cb41f63b91ab8..e85b0db738960 100644 --- a/modules/web/routemock.go +++ b/modules/web/routemock.go @@ -14,14 +14,14 @@ const MockAfterMiddlewares = "MockAfterMiddlewares" var routeMockPoints = map[string]func(next http.Handler) http.Handler{} -// RouteMockPoint registers a mock point as a middleware for testing, example: +// RouterMockPoint registers a mock point as a middleware for testing, example: // -// r.Use(web.RouteMockPoint("my-mock-point-1")) -// r.Get("/foo", middleware2, web.RouteMockPoint("my-mock-point-2"), middleware2, handler) +// r.Use(web.RouterMockPoint("my-mock-point-1")) +// r.Get("/foo", middleware2, web.RouterMockPoint("my-mock-point-2"), middleware2, handler) // // Then use web.RouteMock to mock the route execution. // It only takes effect in testing mode (setting.IsInTesting == true). -func RouteMockPoint(pointName string) func(next http.Handler) http.Handler { +func RouterMockPoint(pointName string) func(next http.Handler) http.Handler { if !setting.IsInTesting { return nil } diff --git a/modules/web/routemock_test.go b/modules/web/routemock_test.go index 04c6d1d82e576..89cfaacdd113b 100644 --- a/modules/web/routemock_test.go +++ b/modules/web/routemock_test.go @@ -16,7 +16,7 @@ import ( func TestRouteMock(t *testing.T) { setting.IsInTesting = true - r := NewRoute() + r := NewRouter() middleware1 := func(resp http.ResponseWriter, req *http.Request) { resp.Header().Set("X-Test-Middleware1", "m1") } @@ -26,7 +26,7 @@ func TestRouteMock(t *testing.T) { handler := func(resp http.ResponseWriter, req *http.Request) { resp.Header().Set("X-Test-Handler", "h") } - r.Get("/foo", middleware1, RouteMockPoint("mock-point"), middleware2, handler) + r.Get("/foo", middleware1, RouterMockPoint("mock-point"), middleware2, handler) // normal request recorder := httptest.NewRecorder() diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini index 10c5a0fc5d2c4..7f65e1317172c 100644 --- a/options/locale/locale_cs-CZ.ini +++ b/options/locale/locale_cs-CZ.ini @@ -93,6 +93,7 @@ remove_all=Odstranit vše remove_label_str=Odstranit položku „%s“ edit=Upravit view=Zobrazit +test=Test enabled=Povolený disabled=Zakázané @@ -3223,6 +3224,10 @@ config.cache_adapter=Adaptér mezipaměti config.cache_interval=Interval mezipaměti config.cache_conn=Připojení mezipaměti config.cache_item_ttl=Čas vypršení položky v mezipaměti +config.cache_test=Otestovat cache +config.cache_test_failed=Test cache se nezdařil: %v. +config.cache_test_slow=Test cache byl úspěšný, ale reakce je pomalá: %s. +config.cache_test_succeeded=Test mezipaměti byl úspěšný, odpověď za %s. config.session_config=Nastavení relace config.session_provider=Poskytovatel relace diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini index bf7bd492f83f0..1fc2a05e6b0a3 100644 --- a/options/locale/locale_pt-PT.ini +++ b/options/locale/locale_pt-PT.ini @@ -93,6 +93,7 @@ remove_all=Remover tudo remove_label_str=`Remover item "%s"` edit=Editar view=Ver +test=Teste enabled=Habilitado disabled=Desabilitado @@ -3224,6 +3225,10 @@ config.cache_adapter=Adaptador de cache config.cache_interval=Intervalo de cache config.cache_conn=Conexão de cache config.cache_item_ttl=TTL do item de cache +config.cache_test=Teste da cache +config.cache_test_failed=Fahou ao sondar a cache: %v. +config.cache_test_slow=O teste da cache foi bem sucedido, mas a resposta é lenta: %s. +config.cache_test_succeeded=O teste da cache foi bem sucedido, obtive resposta em %s. config.session_config=Configuração de sessão config.session_provider=Fornecedor da sessão diff --git a/package-lock.json b/package-lock.json index 3d6c6586972a4..c01d02da1a778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,19 +5,19 @@ "packages": { "": { "dependencies": { - "@citation-js/core": "0.7.11", - "@citation-js/plugin-bibtex": "0.7.12", - "@citation-js/plugin-csl": "0.7.11", + "@citation-js/core": "0.7.14", + "@citation-js/plugin-bibtex": "0.7.14", + "@citation-js/plugin-csl": "0.7.14", "@citation-js/plugin-software-formats": "0.6.1", "@github/markdown-toolbar-element": "2.2.3", "@github/relative-time-element": "4.4.2", - "@github/text-expander-element": "2.6.1", + "@github/text-expander-element": "2.7.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", "@silverwind/vue3-calendar-heatmap": "2.0.6", "add-asset-webpack-plugin": "3.0.0", "ansi_up": "6.0.2", - "asciinema-player": "3.7.1", + "asciinema-player": "3.8.0", "chart.js": "4.4.3", "chartjs-adapter-dayjs-4": "1.0.4", "chartjs-plugin-zoom": "2.0.1", @@ -26,10 +26,10 @@ "dayjs": "1.11.11", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", - "esbuild-loader": "4.1.0", + "esbuild-loader": "4.2.0", "escape-goat": "4.0.0", "fast-glob": "3.3.2", - "htmx.org": "1.9.12", + "htmx.org": "2.0.0", "idiomorph": "0.3.0", "jquery": "3.7.1", "katex": "0.16.10", @@ -44,21 +44,22 @@ "postcss-loader": "8.1.1", "postcss-nesting": "12.1.5", "sortablejs": "1.15.2", - "swagger-ui-dist": "5.17.13", - "tailwindcss": "3.4.3", - "temporal-polyfill": "0.2.4", + "swagger-ui-dist": "5.17.14", + "tailwindcss": "3.4.4", + "temporal-polyfill": "0.2.5", "throttle-debounce": "5.0.0", "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "toastify-js": "1.12.0", "tributejs": "5.1.3", + "typescript": "5.4.5", "uint8-to-base64": "0.2.0", "vanilla-colorful": "0.7.2", - "vue": "3.4.27", + "vue": "3.4.29", "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.1", "vue-loader": "17.4.2", - "webpack": "5.91.0", + "webpack": "5.92.0", "webpack-cli": "5.1.4", "wrap-ansi": "9.0.0" }, @@ -66,38 +67,36 @@ "@eslint-community/eslint-plugin-eslint-comments": "4.3.0", "@playwright/test": "1.44.1", "@stoplight/spectral-cli": "6.11.1", - "@stylistic/eslint-plugin-js": "2.1.0", + "@stylistic/eslint-plugin-js": "2.2.1", "@stylistic/stylelint-plugin": "2.1.2", "@typescript-eslint/parser": "7.13.1", - "@vitejs/plugin-vue": "5.0.4", + "@vitejs/plugin-vue": "5.0.5", "eslint": "8.57.0", "eslint-import-resolver-typescript": "3.6.1", "eslint-plugin-array-func": "4.0.0", - "eslint-plugin-github": "5.0.0-2", + "eslint-plugin-github": "5.0.1", "eslint-plugin-i": "2.29.1", - "eslint-plugin-jquery": "1.5.1", - "eslint-plugin-no-jquery": "2.7.0", + "eslint-plugin-no-jquery": "3.0.1", "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-playwright": "1.6.2", "eslint-plugin-regexp": "2.6.0", "eslint-plugin-sonarjs": "1.0.3", - "eslint-plugin-unicorn": "53.0.0", + "eslint-plugin-unicorn": "54.0.0", "eslint-plugin-vitest": "0.4.1", "eslint-plugin-vitest-globals": "1.5.0", "eslint-plugin-vue": "9.26.0", "eslint-plugin-vue-scoped-css": "2.8.0", "eslint-plugin-wc": "2.1.0", - "happy-dom": "14.11.1", + "happy-dom": "14.12.0", "markdownlint-cli": "0.41.0", "postcss-html": "1.7.0", - "stylelint": "16.6.0", + "stylelint": "16.6.1", "stylelint-declaration-block-no-ignored-properties": "2.8.0", "stylelint-declaration-strict-value": "1.10.4", "stylelint-value-no-unknown-custom-properties": "6.0.1", "svgo": "3.3.2", - "typescript": "5.4.5", - "updates": "16.1.1", - "vite-string-plugin": "1.3.1", + "updates": "16.2.0", + "vite-string-plugin": "1.3.4", "vitest": "1.6.0" }, "engines": { @@ -125,11 +124,11 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.6.tgz", - "integrity": "sha512-ZJhac6FkEd1yhG2AHOmfcXG4ceoLltoCVJjN5XsWN9BifBQr+cHJbWi0h68HZuSORq+3WtJ2z0hwF2NG1b5kcA==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", + "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", "dependencies": { - "@babel/highlight": "^7.24.6", + "@babel/highlight": "^7.24.7", "picocolors": "^1.0.0" }, "engines": { @@ -137,19 +136,19 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.6.tgz", - "integrity": "sha512-4yA7s865JHaqUdRbnaxarZREuPTHrjpDT+pXoAZ1yhyo6uFnIEpS8VMu16siFOHDpZNKYv5BObhsB//ycbICyw==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", + "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.6.tgz", - "integrity": "sha512-2YnuOp4HAk2BsBrJJvYCbItHx0zWscI1C3zgWkz+wDyD9I7GIVrfnLyrR4Y1VR+7p+chAEcrgRQYZAGIKMV7vQ==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", + "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", "dependencies": { - "@babel/helper-validator-identifier": "^7.24.6", + "@babel/helper-validator-identifier": "^7.24.7", "chalk": "^2.4.2", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" @@ -228,9 +227,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.6.tgz", - "integrity": "sha512-eNZXdfU35nJC2h24RznROuOpO94h6x8sg9ju0tT9biNtLZ2vuP8SduLqqV+/8+cebSLV9SJEAN5Z3zQbJG/M+Q==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.7.tgz", + "integrity": "sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==", "bin": { "parser": "bin/babel-parser.js" }, @@ -239,9 +238,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.6.tgz", - "integrity": "sha512-Ja18XcETdEl5mzzACGd+DKgaGJzPTCow7EglgwTmHdwokzDFYh/MHua6lU6DV/hjF2IaOJ4oX2nqnjG7RElKOw==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", + "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -255,9 +254,9 @@ "integrity": "sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==" }, "node_modules/@citation-js/core": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/@citation-js/core/-/core-0.7.11.tgz", - "integrity": "sha512-evQtyzeW+Gbmq+xWciIq9sbcvXXDbm8q32orD/HDd5ay6RQFKoW/BKxBLp+Nmpxgspb9sxTJn3iFK7+jxOTNTw==", + "version": "0.7.14", + "resolved": "https://registry.npmjs.org/@citation-js/core/-/core-0.7.14.tgz", + "integrity": "sha512-dgeGqYDSQmn2MtnWZkwPGpJQPh43yr1lAAr9jl1NJ9pIY1RXUQxtlAUZVur0V9PHdbfQC+kkvB1KC3VpgVV3MA==", "dependencies": { "@citation-js/date": "^0.5.0", "@citation-js/name": "^0.4.2", @@ -285,9 +284,9 @@ } }, "node_modules/@citation-js/plugin-bibtex": { - "version": "0.7.12", - "resolved": "https://registry.npmjs.org/@citation-js/plugin-bibtex/-/plugin-bibtex-0.7.12.tgz", - "integrity": "sha512-cvby0llm1a1kjvvN9ivKO3dCFoyljKx2Rn9mMsUm43JTJZ4rP0emAZ8qzRL4cL3IIUaCRgkN36O+uz9yPktC5Q==", + "version": "0.7.14", + "resolved": "https://registry.npmjs.org/@citation-js/plugin-bibtex/-/plugin-bibtex-0.7.14.tgz", + "integrity": "sha512-xHOHqhF6dthLRv46N9U+mQgYLiiWQHLvQWK9+mcBKz+/3NWge62Xb1oBouNWwLEPd5FV/8gp9fp7SOp93T0dUg==", "dependencies": { "@citation-js/date": "^0.5.0", "@citation-js/name": "^0.4.2", @@ -313,9 +312,9 @@ } }, "node_modules/@citation-js/plugin-csl": { - "version": "0.7.11", - "resolved": "https://registry.npmjs.org/@citation-js/plugin-csl/-/plugin-csl-0.7.11.tgz", - "integrity": "sha512-4OGZ9wHZDfpgiPU2cOXWGuKt7P+ndGWAeLG95nOG+DXe5U+f9EEZTXfaM4C99x8Ri+g6JklR96A3kuYZxYLllg==", + "version": "0.7.14", + "resolved": "https://registry.npmjs.org/@citation-js/plugin-csl/-/plugin-csl-0.7.14.tgz", + "integrity": "sha512-7AKB8lMz1IqdtoE33NnWIpteLYMuSl3xqT+Cax7sQKwAIJEoq2HBmb43Ja8xQQ36nREAupQJv1V6XksIAmYnCg==", "dependencies": { "@citation-js/date": "^0.5.0", "citeproc": "^2.4.6" @@ -514,9 +513,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz", - "integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", "cpu": [ "ppc64" ], @@ -529,9 +528,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz", - "integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", "cpu": [ "arm" ], @@ -544,9 +543,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz", - "integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", "cpu": [ "arm64" ], @@ -559,9 +558,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz", - "integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", "cpu": [ "x64" ], @@ -574,9 +573,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz", - "integrity": "sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", "cpu": [ "arm64" ], @@ -589,9 +588,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz", - "integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", "cpu": [ "x64" ], @@ -604,9 +603,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz", - "integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", "cpu": [ "arm64" ], @@ -619,9 +618,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz", - "integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", "cpu": [ "x64" ], @@ -634,9 +633,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz", - "integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", "cpu": [ "arm" ], @@ -649,9 +648,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz", - "integrity": "sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", "cpu": [ "arm64" ], @@ -664,9 +663,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz", - "integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", "cpu": [ "ia32" ], @@ -679,9 +678,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz", - "integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", "cpu": [ "loong64" ], @@ -694,9 +693,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz", - "integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", "cpu": [ "mips64el" ], @@ -709,9 +708,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz", - "integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", "cpu": [ "ppc64" ], @@ -724,9 +723,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz", - "integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", "cpu": [ "riscv64" ], @@ -739,9 +738,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz", - "integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", "cpu": [ "s390x" ], @@ -754,9 +753,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", - "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", "cpu": [ "x64" ], @@ -769,9 +768,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz", - "integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", "cpu": [ "x64" ], @@ -784,9 +783,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz", - "integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", "cpu": [ "x64" ], @@ -799,9 +798,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz", - "integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", "cpu": [ "x64" ], @@ -814,9 +813,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz", - "integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", "cpu": [ "arm64" ], @@ -829,9 +828,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz", - "integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", "cpu": [ "ia32" ], @@ -844,9 +843,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz", - "integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", "cpu": [ "x64" ], @@ -902,9 +901,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", + "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -1037,17 +1036,19 @@ "integrity": "sha512-wTXunu3hmuGljA5CHaaoUIKV0oI35wno0FKJl2yqKplTRnsCA5bPNj4bDeVIubkuskql6jwionWLlGM1Y6QLaw==" }, "node_modules/@github/text-expander-element": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@github/text-expander-element/-/text-expander-element-2.6.1.tgz", - "integrity": "sha512-i6krPGXJRABfKXut0WArFd365Je4PT0MljtDoXUoCOEp+lGrmdosDMxmO0EfOYc97jBn+Hd2XO1mMsuI5+fwmQ==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@github/text-expander-element/-/text-expander-element-2.7.1.tgz", + "integrity": "sha512-CWxfYxJRkeWVCUhJveproLs6pHsPrWtK8TsjL8ByYVcSCs8CJmNzF8b7ZawrUgfai0F2jb4aIdw2FoBTykj9XA==", "dependencies": { - "@github/combobox-nav": "^2.0.2" + "@github/combobox-nav": "^2.0.2", + "dom-input-range": "^1.1.6" } }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "deprecated": "Use @eslint/config-array instead", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^2.0.2", @@ -1097,6 +1098,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", "dev": true }, "node_modules/@isaacs/cliui": { @@ -1937,9 +1939,9 @@ } }, "node_modules/@stoplight/spectral-functions": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/@stoplight/spectral-functions/-/spectral-functions-1.7.2.tgz", - "integrity": "sha512-f+61/FtIkQeIo+a269CeaeqjpyRsgDyIk6DGr7iS4hyuk1PPk7Uf6MNRDs9FEIBh7CpdEJ+HSHbMLwgpymWTIw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@stoplight/spectral-functions/-/spectral-functions-1.8.0.tgz", + "integrity": "sha512-ZrAkYA/ZGbuQ6EyG1gisF4yQ5nWP/+glcqVoGmS6kH6ekaynz2Yp6FL0oIamWj3rWedFUN7ppwTRUdo+9f/uCw==", "dev": true, "dependencies": { "@stoplight/better-ajv-errors": "1.0.3", @@ -2076,9 +2078,9 @@ "dev": true }, "node_modules/@stoplight/spectral-rulesets": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/@stoplight/spectral-rulesets/-/spectral-rulesets-1.18.1.tgz", - "integrity": "sha512-buLzYi4rHjZOG2d5LC/s3YpySrCGrwR4irKDyrxLlbbqmB8BDOsrdO+7G9UGvRCJwAy/xs1VWcjokzGnG68K+Q==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/@stoplight/spectral-rulesets/-/spectral-rulesets-1.19.1.tgz", + "integrity": "sha512-rfGK87Y1JJCEeLC8MVdLkjUkRH+Y6VnSF388D+UWihfU9xuq2eNB9phWpTFkG+AG4HLRyGx963BmO6PyM9dBag==", "dev": true, "dependencies": { "@asyncapi/specs": "^4.1.0", @@ -2090,9 +2092,10 @@ "@stoplight/spectral-runtime": "^1.1.1", "@stoplight/types": "^13.6.0", "@types/json-schema": "^7.0.7", - "ajv": "^8.8.2", + "ajv": "^8.12.0", "ajv-formats": "~2.1.0", "json-schema-traverse": "^1.0.0", + "leven": "3.1.0", "lodash": "~4.17.21", "tslib": "^2.3.0" }, @@ -2179,9 +2182,9 @@ } }, "node_modules/@stylistic/eslint-plugin-js": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.1.0.tgz", - "integrity": "sha512-gdXUjGNSsnY6nPyqxu6lmDTtVrwCOjun4x8PUn0x04d5ucLI74N3MT1Q0UhdcOR9No3bo5PGDyBgXK+KmD787A==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.2.1.tgz", + "integrity": "sha512-M2dQkKw2R4R+b1SJ/xElJ9bDVq/vCI31VpIIxkZD9KXCqbUHvtsGpZH3eO6MzmFWOZj4PfNdEQdP332MtqjCPg==", "dev": true, "dependencies": { "@types/eslint": "^8.56.10", @@ -2328,9 +2331,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.12.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", - "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "version": "20.14.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.3.tgz", + "integrity": "sha512-Nuzqa6WAxeGnve6SXqiPAM9rA++VQs+iLZ1DDd56y0gdvygSZlQvZuvdFPR3yLqkVxPu4WrO02iDEyH1g+wazw==", "dependencies": { "undici-types": "~5.26.4" } @@ -2367,16 +2370,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.10.0.tgz", - "integrity": "sha512-PzCr+a/KAef5ZawX7nbyNwBDtM1HdLIT53aSA2DDlxmxMngZ43O8SIePOeX8H5S+FHXeI6t97mTt/dDdzY4Fyw==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.1.tgz", + "integrity": "sha512-kZqi+WZQaZfPKnsflLJQCz6Ze9FFSMfXrrIOcyargekQxG37ES7DJNpJUE9Q/X5n3yTIP/WPutVNzgknQ7biLg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.10.0", - "@typescript-eslint/type-utils": "7.10.0", - "@typescript-eslint/utils": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0", + "@typescript-eslint/scope-manager": "7.13.1", + "@typescript-eslint/type-utils": "7.13.1", + "@typescript-eslint/utils": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -2427,7 +2430,7 @@ } } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "node_modules/@typescript-eslint/scope-manager": { "version": "7.13.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz", "integrity": "sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==", @@ -2444,101 +2447,14 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", - "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", - "dev": true, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", - "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", - "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "7.13.1", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/parser/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.10.0.tgz", - "integrity": "sha512-7L01/K8W/VGl7noe2mgH0K7BE29Sq6KAbVmxurj8GGaPDZXPr8EEQ2seOeAS+mEV9DnzxBQB6ax6qQQ5C6P4xg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.10.0.tgz", - "integrity": "sha512-D7tS4WDkJWrVkuzgm90qYw9RdgBcrWmbbRkrLA4d7Pg3w0ttVGDsvYGV19SH8gPR5L7OtcN5J1hTtyenO9xE9g==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.13.1.tgz", + "integrity": "sha512-aWDbLu1s9bmgPGXSzNCxELu+0+HQOapV/y+60gPXafR8e2g1Bifxzevaa+4L2ytCWm+CHqpELq4CSoN9ELiwCg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.10.0", - "@typescript-eslint/utils": "7.10.0", + "@typescript-eslint/typescript-estree": "7.13.1", + "@typescript-eslint/utils": "7.13.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -2559,9 +2475,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.10.0.tgz", - "integrity": "sha512-7fNj+Ya35aNyhuqrA1E/VayQX9Elwr8NKZ4WueClR3KwJ7Xx9jcCdOrLW04h51de/+gNbyFMs+IDxh5xIwfbNg==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", + "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2572,13 +2488,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.10.0.tgz", - "integrity": "sha512-LXFnQJjL9XIcxeVfqmNj60YhatpRLt6UhdlFwAkjNc6jSUlK8zQOl1oktAP8PlWFzPQC1jny/8Bai3/HPuvN5g==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", + "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/visitor-keys": "7.10.0", + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2600,15 +2516,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.10.0.tgz", - "integrity": "sha512-olzif1Fuo8R8m/qKkzJqT7qwy16CzPRWBvERS0uvyc+DHd8AKbO4Jb7kpAvVzMmZm8TrHnI7hvjN4I05zow+tg==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.1.tgz", + "integrity": "sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.10.0", - "@typescript-eslint/types": "7.10.0", - "@typescript-eslint/typescript-estree": "7.10.0" + "@typescript-eslint/scope-manager": "7.13.1", + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/typescript-estree": "7.13.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -2622,12 +2538,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.10.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.10.0.tgz", - "integrity": "sha512-9ntIVgsi6gg6FIq9xjEO4VQJvwOqA3jaBFQJ/6TK5AvEup2+cECI6Fh7QiBxmfMHXU0V0J4RyPeOU1VDNzl9cg==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", + "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.10.0", + "@typescript-eslint/types": "7.13.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -2657,9 +2573,9 @@ "dev": true }, "node_modules/@vitejs/plugin-vue": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.4.tgz", - "integrity": "sha512-WS3hevEszI6CEVEx28F8RjTX97k3KsrcY6kvTg7+Whm5y3oYvcqzVeGCU3hxSAn4uY2CLCkeokkGKpoctccilQ==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.0.5.tgz", + "integrity": "sha512-LOjm7XeIimLBZyzinBQ6OSm3UBCNVCpLkxGC0oWmm2YPzVZoxMsdvNVimLTBzpAnR9hl/yn1SHGuRfe6/Td9rQ==", "dev": true, "engines": { "node": "^18.0.0 || >=20.0.0" @@ -2790,36 +2706,36 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.27.tgz", - "integrity": "sha512-E+RyqY24KnyDXsCuQrI+mlcdW3ALND6U7Gqa/+bVwbcpcR3BRRIckFoz7Qyd4TTlnugtwuI7YgjbvsLmxb+yvg==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.29.tgz", + "integrity": "sha512-TFKiRkKKsRCKvg/jTSSKK7mYLJEQdUiUfykbG49rubC9SfDyvT2JrzTReopWlz2MxqeLyxh9UZhvxEIBgAhtrg==", "dependencies": { - "@babel/parser": "^7.24.4", - "@vue/shared": "3.4.27", + "@babel/parser": "^7.24.7", + "@vue/shared": "3.4.29", "entities": "^4.5.0", "estree-walker": "^2.0.2", "source-map-js": "^1.2.0" } }, "node_modules/@vue/compiler-dom": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.27.tgz", - "integrity": "sha512-kUTvochG/oVgE1w5ViSr3KUBh9X7CWirebA3bezTbB5ZKBQZwR2Mwj9uoSKRMFcz4gSMzzLXBPD6KpCLb9nvWw==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.29.tgz", + "integrity": "sha512-A6+iZ2fKIEGnfPJejdB7b1FlJzgiD+Y/sxxKwJWg1EbJu6ZPgzaPQQ51ESGNv0CP6jm6Z7/pO6Ia8Ze6IKrX7w==", "dependencies": { - "@vue/compiler-core": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-core": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.27.tgz", - "integrity": "sha512-nDwntUEADssW8e0rrmE0+OrONwmRlegDA1pD6QhVeXxjIytV03yDqTey9SBDiALsvAd5U4ZrEKbMyVXhX6mCGA==", - "dependencies": { - "@babel/parser": "^7.24.4", - "@vue/compiler-core": "3.4.27", - "@vue/compiler-dom": "3.4.27", - "@vue/compiler-ssr": "3.4.27", - "@vue/shared": "3.4.27", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.29.tgz", + "integrity": "sha512-zygDcEtn8ZimDlrEQyLUovoWgKQic6aEQqRXce2WXBvSeHbEbcAsXyCk9oG33ZkyWH4sl9D3tkYc1idoOkdqZQ==", + "dependencies": { + "@babel/parser": "^7.24.7", + "@vue/compiler-core": "3.4.29", + "@vue/compiler-dom": "3.4.29", + "@vue/compiler-ssr": "3.4.29", + "@vue/shared": "3.4.29", "estree-walker": "^2.0.2", "magic-string": "^0.30.10", "postcss": "^8.4.38", @@ -2835,57 +2751,58 @@ } }, "node_modules/@vue/compiler-ssr": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.27.tgz", - "integrity": "sha512-CVRzSJIltzMG5FcidsW0jKNQnNRYC8bT21VegyMMtHmhW3UOI7knmUehzswXLrExDLE6lQCZdrhD4ogI7c+vuw==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.29.tgz", + "integrity": "sha512-rFbwCmxJ16tDp3N8XCx5xSQzjhidYjXllvEcqX/lopkoznlNPz3jyy0WGJCyhAaVQK677WWFt3YO/WUEkMMUFQ==", "dependencies": { - "@vue/compiler-dom": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-dom": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/reactivity": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.27.tgz", - "integrity": "sha512-kK0g4NknW6JX2yySLpsm2jlunZJl2/RJGZ0H9ddHdfBVHcNzxmQ0sS0b09ipmBoQpY8JM2KmUw+a6sO8Zo+zIA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.29.tgz", + "integrity": "sha512-w8+KV+mb1a8ornnGQitnMdLfE0kXmteaxLdccm2XwdFxXst4q/Z7SEboCV5SqJNpZbKFeaRBBJBhW24aJyGINg==", "dependencies": { - "@vue/shared": "3.4.27" + "@vue/shared": "3.4.29" } }, "node_modules/@vue/runtime-core": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.27.tgz", - "integrity": "sha512-7aYA9GEbOOdviqVvcuweTLe5Za4qBZkUY7SvET6vE8kyypxVgaT1ixHLg4urtOlrApdgcdgHoTZCUuTGap/5WA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.29.tgz", + "integrity": "sha512-s8fmX3YVR/Rk5ig0ic0NuzTNjK2M7iLuVSZyMmCzN/+Mjuqqif1JasCtEtmtoJWF32pAtUjyuT2ljNKNLeOmnQ==", "dependencies": { - "@vue/reactivity": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/reactivity": "3.4.29", + "@vue/shared": "3.4.29" } }, "node_modules/@vue/runtime-dom": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.27.tgz", - "integrity": "sha512-ScOmP70/3NPM+TW9hvVAz6VWWtZJqkbdf7w6ySsws+EsqtHvkhxaWLecrTorFxsawelM5Ys9FnDEMt6BPBDS0Q==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.29.tgz", + "integrity": "sha512-gI10atCrtOLf/2MPPMM+dpz3NGulo9ZZR9d1dWo4fYvm+xkfvRrw1ZmJ7mkWtiJVXSsdmPbcK1p5dZzOCKDN0g==", "dependencies": { - "@vue/runtime-core": "3.4.27", - "@vue/shared": "3.4.27", + "@vue/reactivity": "3.4.29", + "@vue/runtime-core": "3.4.29", + "@vue/shared": "3.4.29", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.27.tgz", - "integrity": "sha512-dlAMEuvmeA3rJsOMJ2J1kXU7o7pOxgsNHVr9K8hB3ImIkSuBrIdy0vF66h8gf8Tuinf1TK3mPAz2+2sqyf3KzA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.29.tgz", + "integrity": "sha512-HMLCmPI2j/k8PVkSBysrA2RxcxC5DgBiCdj7n7H2QtR8bQQPqKAe8qoaxLcInzouBmzwJ+J0x20ygN/B5mYBng==", "dependencies": { - "@vue/compiler-ssr": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-ssr": "3.4.29", + "@vue/shared": "3.4.29" }, "peerDependencies": { - "vue": "3.4.27" + "vue": "3.4.29" } }, "node_modules/@vue/shared": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.27.tgz", - "integrity": "sha512-DL3NmY2OFlqmYYrzp39yi3LDkKxa5vZVwxWdQ3rG0ekuWscHraeIbnI8t+aZK7qhYqEqWKTUdijadunb9pnrgA==" + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.29.tgz", + "integrity": "sha512-hQ2gAQcBO/CDpC82DCrinJNgOHI2v+FA7BDW4lMSPeBpQ7sRe2OLHWe5cph1s7D8DUQAwRt18dBDfJJ220APEA==" }, "node_modules/@webassemblyjs/ast": { "version": "1.12.1", @@ -3082,9 +2999,9 @@ } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "bin": { "acorn": "bin/acorn" }, @@ -3092,10 +3009,10 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-assertions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", - "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", + "node_modules/acorn-import-attributes": { + "version": "1.9.5", + "resolved": "https://registry.npmjs.org/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz", + "integrity": "sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==", "peerDependencies": { "acorn": "^8" } @@ -3110,10 +3027,13 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", - "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", + "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, "engines": { "node": ">=0.4.0" } @@ -3133,9 +3053,9 @@ } }, "node_modules/ajv": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.14.0.tgz", - "integrity": "sha512-oYs1UUtO97ZO2lJ4bwnWeQW8/zvOIQLGKcvPTsWmvc2SYgBb+upuNS5NxoLaMU4h8Ju3Nbj6Cq8mD2LQoqVKFA==", + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.16.0.tgz", + "integrity": "sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==", "dependencies": { "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", @@ -3404,9 +3324,9 @@ } }, "node_modules/asciinema-player": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/asciinema-player/-/asciinema-player-3.7.1.tgz", - "integrity": "sha512-zDJteGjBzNQhHEnD0aG7GqV3E53sOyKb1WCxKNRm2PquU70Lq3s4xxb91wyDS0hBJ3J/TB8aY3y8gjGPN+T23A==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/asciinema-player/-/asciinema-player-3.8.0.tgz", + "integrity": "sha512-yFoAcjFK9WJ0D+aagkT0YXOWRbyXoOe/TQHq07oQP6prItXQkWn46fdvUb6zqJu2AywmY8VjBEwZ6ciL8IbezQ==", "dependencies": { "@babel/runtime": "^7.21.0", "solid-js": "^1.3.0" @@ -3571,9 +3491,9 @@ } }, "node_modules/browserslist": { - "version": "4.23.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", - "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", + "version": "4.23.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.1.tgz", + "integrity": "sha512-TUfofFo/KsK/bWZ9TWQ5O26tsWW4Uhmt8IYklbnUa70udB6P2wA7w7o4PY4muaEPBQaAX+CEnmmIA41NVHtPVw==", "funding": [ { "type": "opencollective", @@ -3589,10 +3509,10 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001587", - "electron-to-chromium": "^1.4.668", + "caniuse-lite": "^1.0.30001629", + "electron-to-chromium": "^1.4.796", "node-releases": "^2.0.14", - "update-browserslist-db": "^1.0.13" + "update-browserslist-db": "^1.0.16" }, "bin": { "browserslist": "cli.js" @@ -3692,9 +3612,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001623", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001623.tgz", - "integrity": "sha512-X/XhAVKlpIxWPpgRTnlgZssJrF0m6YtRA0QDWgsBNT12uZM6LPRydR7ip405Y3t1LamD8cP2TZFEDZFBf5ApcA==", + "version": "1.0.30001636", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", + "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", "funding": [ { "type": "opencollective", @@ -3833,9 +3753,9 @@ } }, "node_modules/chrome-trace-event": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", - "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.4.tgz", + "integrity": "sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==", "engines": { "node": ">=6.0" } @@ -4725,9 +4645,9 @@ "integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==" }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dependencies": { "ms": "2.1.2" }, @@ -4762,9 +4682,9 @@ } }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", "dev": true, "dependencies": { "type-detect": "^4.0.0" @@ -4898,6 +4818,14 @@ "node": ">=6.0.0" } }, + "node_modules/dom-input-range": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/dom-input-range/-/dom-input-range-1.1.6.tgz", + "integrity": "sha512-4o/SkTpscD0n81BeErrrtmE58lG8vTks++92vk//ld0NmkQTb4AVJ2rexh2yor6rtBf5IMte26u+fF3EgCppPQ==", + "workspaces": [ + "demos" + ] + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -4940,9 +4868,9 @@ } }, "node_modules/dompurify": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.4.tgz", - "integrity": "sha512-2gnshi6OshmuKil8rMZuQCGiUF3cUxHY3NGDzUAdUx/NPEe5DVnO8BDoAQouvgwnx0R/+a6jUn36Z0FSdq8vww==" + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.5.tgz", + "integrity": "sha512-lwG+n5h8QNpxtyrJW/gJWckL+1/DQiYMX8f7t8Z2AZTPw1esVrqjI63i7Zc2Gz0aKzLVMYC1V1PL/ky+aY/NgA==" }, "node_modules/domutils": { "version": "3.1.0", @@ -4985,9 +4913,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.783", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.783.tgz", - "integrity": "sha512-bT0jEz/Xz1fahQpbZ1D7LgmPYZ3iHVY39NcWWro1+hA2IvjiPeaXtfSqrQ+nXjApMvQRE2ASt1itSLRrebHMRQ==" + "version": "1.4.803", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.803.tgz", + "integrity": "sha512-61H9mLzGOCLLVsnLiRzCbc63uldP0AniRYPV3hbGVtONA1pI7qSGILdbofR7A8TMbOypDocEAjH/e+9k1QIe3g==" }, "node_modules/elkjs": { "version": "0.9.3", @@ -5008,9 +4936,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.1.tgz", - "integrity": "sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==", + "version": "5.17.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz", + "integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==", "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.2.0" @@ -5243,9 +5171,9 @@ } }, "node_modules/esbuild": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", - "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" @@ -5254,37 +5182,37 @@ "node": ">=12" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.20.2", - "@esbuild/android-arm": "0.20.2", - "@esbuild/android-arm64": "0.20.2", - "@esbuild/android-x64": "0.20.2", - "@esbuild/darwin-arm64": "0.20.2", - "@esbuild/darwin-x64": "0.20.2", - "@esbuild/freebsd-arm64": "0.20.2", - "@esbuild/freebsd-x64": "0.20.2", - "@esbuild/linux-arm": "0.20.2", - "@esbuild/linux-arm64": "0.20.2", - "@esbuild/linux-ia32": "0.20.2", - "@esbuild/linux-loong64": "0.20.2", - "@esbuild/linux-mips64el": "0.20.2", - "@esbuild/linux-ppc64": "0.20.2", - "@esbuild/linux-riscv64": "0.20.2", - "@esbuild/linux-s390x": "0.20.2", - "@esbuild/linux-x64": "0.20.2", - "@esbuild/netbsd-x64": "0.20.2", - "@esbuild/openbsd-x64": "0.20.2", - "@esbuild/sunos-x64": "0.20.2", - "@esbuild/win32-arm64": "0.20.2", - "@esbuild/win32-ia32": "0.20.2", - "@esbuild/win32-x64": "0.20.2" + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" } }, "node_modules/esbuild-loader": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/esbuild-loader/-/esbuild-loader-4.1.0.tgz", - "integrity": "sha512-543TtIvqbqouEMlOHg4xKoDQkmdImlwIpyAIgpUtDPvMuklU/c2k+Qt2O3VeDBgAwozxmlEbjOzV+F8CZ0g+Bw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/esbuild-loader/-/esbuild-loader-4.2.0.tgz", + "integrity": "sha512-BhwHchuDknxIa69AqOPeZh2fIFqj2AzZKC1E3RBRvXSuyk5drsqMrwsgYZJufX41yrauLYjDM3KBmruoGl1NWQ==", "dependencies": { - "esbuild": "^0.20.0", + "esbuild": "^0.21.0", "get-tsconfig": "^4.7.0", "loader-utils": "^2.0.4", "webpack-sources": "^1.4.3" @@ -5383,9 +5311,9 @@ } }, "node_modules/eslint-compat-utils": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.0.tgz", - "integrity": "sha512-dc6Y8tzEcSYZMHa+CMPLi/hyo1FzNeonbhJL7Ol0ccuKQkwopJcJBA9YL/xmMTLU1eKigXo9vj9nALElWYSowg==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", "dev": true, "dependencies": { "semver": "^7.5.4" @@ -5548,9 +5476,9 @@ } }, "node_modules/eslint-plugin-github": { - "version": "5.0.0-2", - "resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-5.0.0-2.tgz", - "integrity": "sha512-oQUFAF1wMBvRMGLvGWxVhZ46JNjKbPuuDufmUDZ3ZYyovWHCqqR5HLHTpTfmZQcyEXmjv9TWdsgfdMlod2fGMQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-github/-/eslint-plugin-github-5.0.1.tgz", + "integrity": "sha512-qbXG3wL5Uh2JB92EKeX2hPtO9c/t75qVxQjVLYuTFfhHifLZzv9CBvLCvoaBhLrAC/xTMVht7DK/NofYK8X4Dg==", "dev": true, "dependencies": { "@github/browserslist-config": "^1.0.0", @@ -5717,15 +5645,6 @@ "semver": "bin/semver.js" } }, - "node_modules/eslint-plugin-jquery": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jquery/-/eslint-plugin-jquery-1.5.1.tgz", - "integrity": "sha512-L7v1eaK5t80C0lvUXPFP9MKnBOqPSKhCOYyzy4LZ0+iK+TJwN8S9gAkzzP1AOhypRIwA88HF6phQ9C7jnOpW8w==", - "dev": true, - "peerDependencies": { - "eslint": ">=5.4.0" - } - }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.8.0.tgz", @@ -5779,12 +5698,12 @@ } }, "node_modules/eslint-plugin-no-jquery": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-2.7.0.tgz", - "integrity": "sha512-Aeg7dA6GTH1AcWLlBtWNzOU9efK5KpNi7b0EhBO0o0M+awyzguUUo8gF6hXGjQ9n5h8/uRtYv9zOqQkeC5CG0w==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-jquery/-/eslint-plugin-no-jquery-3.0.1.tgz", + "integrity": "sha512-GrzdjIxox/3x8hpSwpxiMuEQFipiJHTGiVsp0T1TI6GH+KVSbXa4z/56xTV1WiIe66u3iRgvCIipu9CRthecpQ==", "dev": true, "peerDependencies": { - "eslint": ">=2.3.0" + "eslint": ">=8.0.0" } }, "node_modules/eslint-plugin-no-only-tests": { @@ -5899,9 +5818,9 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "53.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-53.0.0.tgz", - "integrity": "sha512-kuTcNo9IwwUCfyHGwQFOK/HjJAYzbODHN3wP0PgqbW+jbXqpNWxNVpVhj2tO9SixBwuAdmal8rVcWKBxwFnGuw==", + "version": "54.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-54.0.0.tgz", + "integrity": "sha512-XxYLRiYtAWiAjPv6z4JREby1TAE2byBC7wlh0V4vWDCpccOSU1KovWV//jqPXF6bq3WKxqX9rdjoRQ1EhdmNdQ==", "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.24.5", @@ -6212,12 +6131,12 @@ } }, "node_modules/espree": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", - "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", "dev": true, "dependencies": { - "acorn": "^8.11.3", + "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^4.0.0" }, @@ -6487,9 +6406,9 @@ } }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -6881,9 +6800,9 @@ } }, "node_modules/happy-dom": { - "version": "14.11.1", - "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-14.11.1.tgz", - "integrity": "sha512-JuaGMxD3QlQei6LdAM9mMY9am/cHa978uFbkOpjN5x83DG+QQp/NLyVV4Ru7KOjs70XYZ4KbI0TNiO81nM7uQQ==", + "version": "14.12.0", + "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-14.12.0.tgz", + "integrity": "sha512-dHcnlGFY2o2CdxfuYpqwSrBrpj/Kuzv4u4f3TU5yHW1GL24dKij4pv1BRjXnXc3uWo8qsCbToF9weaDsm/He8A==", "dev": true, "dependencies": { "entities": "^4.5.0", @@ -7025,9 +6944,9 @@ } }, "node_modules/htmx.org": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-1.9.12.tgz", - "integrity": "sha512-VZAohXyF7xPGS52IM8d1T1283y+X4D+Owf3qY1NZ9RuBypyu9l8cGsxUMAG5fEAb/DhT7rDoJ9Hpu5/HxFD3cw==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-2.0.0.tgz", + "integrity": "sha512-N0r1VjrqeCpig0mTi2/sooDZBeQlp1RBohnWQ/ufqc7ICaI0yjs04fNGhawm6+/HWhJFlcXn8MqOjWI9QGG2lQ==" }, "node_modules/human-signals": { "version": "5.0.0", @@ -7706,9 +7625,9 @@ } }, "node_modules/jackspeak": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.1.2.tgz", - "integrity": "sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", + "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dependencies": { "@isaacs/cliui": "^8.0.2" }, @@ -7750,9 +7669,9 @@ } }, "node_modules/jiti": { - "version": "1.21.0", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz", - "integrity": "sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==", + "version": "1.21.6", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.6.tgz", + "integrity": "sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==", "bin": { "jiti": "bin/jiti.js" } @@ -9010,14 +8929,14 @@ } }, "node_modules/mlly": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.0.tgz", - "integrity": "sha512-U9SDaXGEREBYQgfejV97coK0UL1r+qnF2SyO9A3qcI8MzKnsIFKHNVEkrDyNncQTKQQumsasmeq84eNMdBfsNQ==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.1.tgz", + "integrity": "sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==", "dev": true, "dependencies": { "acorn": "^8.11.3", "pathe": "^1.1.2", - "pkg-types": "^1.1.0", + "pkg-types": "^1.1.1", "ufo": "^1.5.3" } }, @@ -9771,6 +9690,51 @@ "postcss": "^8.4.21" } }, + "node_modules/postcss-load-config": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", + "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "lilconfig": "^3.0.0", + "yaml": "^2.3.4" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/postcss-load-config/node_modules/lilconfig": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", + "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, "node_modules/postcss-loader": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-8.1.1.tgz", @@ -9994,9 +9958,9 @@ } }, "node_modules/prettier": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", - "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -10794,9 +10758,9 @@ } }, "node_modules/smol-toml": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.2.0.tgz", - "integrity": "sha512-KObxdQANC/xje3OoatMbSwQf2XAvJ0RbK+4nmQRszFNZptbNRnMWqbLF/zb4sMi9xJ6HNyhWXeuZ9zC/I/XY7w==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.2.1.tgz", + "integrity": "sha512-OtZKrVrGIT+m++lxyF0z5n68nkwdgZotPhy89bfA4T7nSWe0xeQtfbjM1z5VLTilJdWXH46g8i0oAcpQNkzZTg==", "dev": true, "engines": { "node": ">= 18", @@ -11123,9 +11087,9 @@ "dev": true }, "node_modules/stylelint": { - "version": "16.6.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.6.0.tgz", - "integrity": "sha512-vjWYlDEgOS3Z/IcXagQwi8PFJyPro1DxBYOnTML1PAqnrYUHs8owleGStv20sgt0OhW8r9zZm6MK7IT2+l2B6A==", + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.6.1.tgz", + "integrity": "sha512-yNgz2PqWLkhH2hw6X9AweV9YvoafbAD5ZsFdKN9BvSDVwGvPh+AUIrn7lYwy1S7IHmtFin75LLfX1m0D2tHu8Q==", "dev": true, "funding": [ { @@ -11151,7 +11115,7 @@ "debug": "^4.3.4", "fast-glob": "^3.3.2", "fastest-levenshtein": "^1.0.16", - "file-entry-cache": "^8.0.0", + "file-entry-cache": "^9.0.0", "global-modules": "^2.0.0", "globby": "^11.1.0", "globjoin": "^0.1.4", @@ -11162,7 +11126,7 @@ "known-css-properties": "^0.31.0", "mathml-tag-names": "^2.1.3", "meow": "^13.2.0", - "micromatch": "^4.0.5", + "micromatch": "^4.0.7", "normalize-path": "^3.0.0", "picocolors": "^1.0.1", "postcss": "^8.4.38", @@ -11244,28 +11208,28 @@ "dev": true }, "node_modules/stylelint/node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-9.0.0.tgz", + "integrity": "sha512-6MgEugi8p2tiUhqO7GnPsmbCCzj0YRCwwaTbpGRyKZesjRSzkqkAE9fPp7V2yMs5hwfgbQLgdvSSkGNg1s5Uvw==", "dev": true, "dependencies": { - "flat-cache": "^4.0.0" + "flat-cache": "^5.0.0" }, "engines": { - "node": ">=16.0.0" + "node": ">=18" } }, "node_modules/stylelint/node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-5.0.0.tgz", + "integrity": "sha512-JrqFmyUl2PnPi1OvLyTVHnQvwQ0S+e6lGSwu8OkAZlSaNIZciTY2H/cOOROxsBA1m/LZNHDsqAgDZt6akWcjsQ==", "dev": true, "dependencies": { - "flatted": "^3.2.9", + "flatted": "^3.3.1", "keyv": "^4.5.4" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/stylelint/node_modules/postcss-safe-parser": { @@ -11493,9 +11457,9 @@ } }, "node_modules/swagger-ui-dist": { - "version": "5.17.13", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.13.tgz", - "integrity": "sha512-dyR3HAjwjK9oTd5ELzFh7rJEoMUyqfgaAQEwn0NGhLpOwg7IEbee17qjp50QIVE3sUA8J2d6ySw4IF50nUrKog==" + "version": "5.17.14", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.14.tgz", + "integrity": "sha512-CVbSfaLpstV65OnSjbXfVd6Sta3q3F7Cj/yYuvHMp1P90LztOLs6PfUnKEVAeiIVQt9u2SaPwv0LiH/OyMjHRw==" }, "node_modules/sync-fetch": { "version": "0.4.5", @@ -11542,9 +11506,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz", - "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==", + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.4.tgz", + "integrity": "sha512-ZoyXOdJjISB7/BcLTR6SEsLgKtDStYyYZVLsUtWChO4Ps20CBad7lfJKVDiejocV4ME1hLmyY0WJE3hSDcmQ2A==", "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -11577,51 +11541,6 @@ "node": ">=14.0.0" } }, - "node_modules/tailwindcss/node_modules/postcss-load-config": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", - "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "lilconfig": "^3.0.0", - "yaml": "^2.3.4" - }, - "engines": { - "node": ">= 14" - }, - "peerDependencies": { - "postcss": ">=8.0.9", - "ts-node": ">=9.0.0" - }, - "peerDependenciesMeta": { - "postcss": { - "optional": true - }, - "ts-node": { - "optional": true - } - } - }, - "node_modules/tailwindcss/node_modules/postcss-load-config/node_modules/lilconfig": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.1.tgz", - "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/antonk52" - } - }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -11631,9 +11550,9 @@ } }, "node_modules/temporal-polyfill": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.4.tgz", - "integrity": "sha512-WA5p0CjQTkMjF9m8sP4wSYgpqI8m2d4q7wPUyaJOWhy4bI9mReLb2yGvTV4qf/DPMTe6H6M/Dig5KmTMB7ev6Q==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.5.tgz", + "integrity": "sha512-ye47xp8Cb0nDguAhrrDS1JT1SzwEV9e26sSsrWzVu+yPZ7LzceEcH0i2gci9jWfOfSCCgM3Qv5nOYShVUUFUXA==", "dependencies": { "temporal-spec": "^0.2.4" } @@ -11644,9 +11563,9 @@ "integrity": "sha512-lDMFv4nKQrSjlkHKAlHVqKrBG4DyFfa9F74cmBZ3Iy3ed8yvWnlWSIdi4IKfSqwmazAohBNwiN64qGx4y5Q3IQ==" }, "node_modules/terser": { - "version": "5.31.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.0.tgz", - "integrity": "sha512-Q1JFAoUKE5IMfI4Z/lkE/E6+SwgzO+x4tq4v1AyBLRj8VSYvRO6A/rQrPg1yud4g0En9EKI1TvFRF2tQFcoUkg==", + "version": "5.31.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.1.tgz", + "integrity": "sha512-37upzU1+viGvuFtBo9NPufCb9dwM0+l9hMxYyWfBA+fbwrPqNJAhbZ6W47bBFnZHKHTUBnMvi87434qq+qnxOg==", "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", @@ -11889,9 +11808,9 @@ } }, "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "dev": true }, "node_modules/type-check": { @@ -12004,7 +11923,6 @@ "version": "5.4.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -12106,12 +12024,12 @@ } }, "node_modules/updates": { - "version": "16.1.1", - "resolved": "https://registry.npmjs.org/updates/-/updates-16.1.1.tgz", - "integrity": "sha512-h0Qtbmd9RCi6+99D5o7ACq4h7GxdYjeHFlxd4s0iO3lUOUDo1VnOsbNNIyjHpieVEctaEm/zoEjVggCgAcO/vg==", + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/updates/-/updates-16.2.0.tgz", + "integrity": "sha512-9F+tkT12B6f1+zzMKY9CrJx18LwnEh2HLQXtuJgtXobi5BwSQ9BH0b+ZnhwyQuY0lmgLFCsE6QxO98OZJiLX6Q==", "dev": true, "bin": { - "updates": "dist/updates.js" + "updates": "dist/index.js" }, "engines": { "node": ">=18" @@ -12199,12 +12117,12 @@ "integrity": "sha512-z2YZusTFC6KnLERx1cgoIRX2CjPRP0W75N+3CC6gbvdX5Ch47rZkEMGO2Xnf+IEmi3RiFLxS18gayMA27iU7Kg==" }, "node_modules/vite": { - "version": "5.2.11", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz", - "integrity": "sha512-HndV31LWW05i1BLPMUCE1B9E9GFbOu1MbenhS58FuK6owSO5qHm7GiCotrNY1YE5rMeQSFBGmT5ZaLEjFizgiQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", + "integrity": "sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==", "dev": true, "dependencies": { - "esbuild": "^0.20.1", + "esbuild": "^0.21.3", "postcss": "^8.4.38", "rollup": "^4.13.0" }, @@ -12276,9 +12194,9 @@ } }, "node_modules/vite-string-plugin": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/vite-string-plugin/-/vite-string-plugin-1.3.1.tgz", - "integrity": "sha512-0Wu9yNw4QlSVM4SlwozzxR0geMoKFrAIpMldgPuzDvV8lWT1v+0pFXYt+t48qocYXBaxiuVRE3qcsEwFDHBAmA==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/vite-string-plugin/-/vite-string-plugin-1.3.4.tgz", + "integrity": "sha512-mHvcooHgZ0nVbHtj9o+c5dzD2/nclr/SOG023EFYF/zRnO8bxB63bV9WUA9X+njlgLpOwCJ3LI2IdihKoi0gZQ==", "dev": true }, "node_modules/vite/node_modules/@types/estree": { @@ -12411,15 +12329,15 @@ } }, "node_modules/vue": { - "version": "3.4.27", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.27.tgz", - "integrity": "sha512-8s/56uK6r01r1icG/aEOHqyMVxd1bkYcSe9j8HcKtr/xTOFWvnzIVTehNW+5Yt89f+DLBe4A569pnZLS5HzAMA==", + "version": "3.4.29", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.29.tgz", + "integrity": "sha512-8QUYfRcYzNlYuzKPfge1UWC6nF9ym0lx7mpGVPJYNhddxEf3DD0+kU07NTL0sXuiT2HuJuKr/iEO8WvXvT0RSQ==", "dependencies": { - "@vue/compiler-dom": "3.4.27", - "@vue/compiler-sfc": "3.4.27", - "@vue/runtime-dom": "3.4.27", - "@vue/server-renderer": "3.4.27", - "@vue/shared": "3.4.27" + "@vue/compiler-dom": "3.4.29", + "@vue/compiler-sfc": "3.4.29", + "@vue/runtime-dom": "3.4.29", + "@vue/server-renderer": "3.4.29", + "@vue/shared": "3.4.29" }, "peerDependencies": { "typescript": "*" @@ -12449,9 +12367,9 @@ } }, "node_modules/vue-eslint-parser": { - "version": "9.4.2", - "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-9.4.2.tgz", - "integrity": "sha512-Ry9oiGmCAK91HrKMtCrKFWmSFWvYkpGglCeFAIqDdr9zdXmMMpJOmUJS7WWsW7fX81h6mwHmUZCQQ1E0PkSwYQ==", + "version": "9.4.3", + "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-9.4.3.tgz", + "integrity": "sha512-2rYRLWlIpaiN8xbPiDyXZXRgLGOtWxERV7ND5fFAv5qo1D2N9Fu9MNajBNc6o13lZ+24DAWCkQCvj4klgmcITg==", "dev": true, "dependencies": { "debug": "^4.3.4", @@ -12549,9 +12467,9 @@ } }, "node_modules/webpack": { - "version": "5.91.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.91.0.tgz", - "integrity": "sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw==", + "version": "5.92.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.92.0.tgz", + "integrity": "sha512-Bsw2X39MYIgxouNATyVpCNVWBCuUwDgWtN78g6lSdPJRLaQ/PUVm/oXcaRAyY/sMFoKFQrsPeqvTizWtq7QPCA==", "dependencies": { "@types/eslint-scope": "^3.7.3", "@types/estree": "^1.0.5", @@ -12559,10 +12477,10 @@ "@webassemblyjs/wasm-edit": "^1.12.1", "@webassemblyjs/wasm-parser": "^1.12.1", "acorn": "^8.7.1", - "acorn-import-assertions": "^1.9.0", + "acorn-import-attributes": "^1.9.5", "browserslist": "^4.21.10", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.16.0", + "enhanced-resolve": "^5.17.0", "es-module-lexer": "^1.2.1", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -13019,9 +12937,9 @@ } }, "node_modules/yaml": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", - "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", + "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", "bin": { "yaml": "bin.mjs" }, diff --git a/package.json b/package.json index d1a9b8a56fb71..d69421c3520c9 100644 --- a/package.json +++ b/package.json @@ -4,19 +4,19 @@ "node": ">= 18.0.0" }, "dependencies": { - "@citation-js/core": "0.7.11", - "@citation-js/plugin-bibtex": "0.7.12", - "@citation-js/plugin-csl": "0.7.11", + "@citation-js/core": "0.7.14", + "@citation-js/plugin-bibtex": "0.7.14", + "@citation-js/plugin-csl": "0.7.14", "@citation-js/plugin-software-formats": "0.6.1", "@github/markdown-toolbar-element": "2.2.3", "@github/relative-time-element": "4.4.2", - "@github/text-expander-element": "2.6.1", + "@github/text-expander-element": "2.7.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.9.0", "@silverwind/vue3-calendar-heatmap": "2.0.6", "add-asset-webpack-plugin": "3.0.0", "ansi_up": "6.0.2", - "asciinema-player": "3.7.1", + "asciinema-player": "3.8.0", "chart.js": "4.4.3", "chartjs-adapter-dayjs-4": "1.0.4", "chartjs-plugin-zoom": "2.0.1", @@ -25,10 +25,10 @@ "dayjs": "1.11.11", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", - "esbuild-loader": "4.1.0", + "esbuild-loader": "4.2.0", "escape-goat": "4.0.0", "fast-glob": "3.3.2", - "htmx.org": "1.9.12", + "htmx.org": "2.0.0", "idiomorph": "0.3.0", "jquery": "3.7.1", "katex": "0.16.10", @@ -43,21 +43,22 @@ "postcss-loader": "8.1.1", "postcss-nesting": "12.1.5", "sortablejs": "1.15.2", - "swagger-ui-dist": "5.17.13", - "tailwindcss": "3.4.3", - "temporal-polyfill": "0.2.4", + "swagger-ui-dist": "5.17.14", + "tailwindcss": "3.4.4", + "temporal-polyfill": "0.2.5", "throttle-debounce": "5.0.0", "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "toastify-js": "1.12.0", "tributejs": "5.1.3", + "typescript": "5.4.5", "uint8-to-base64": "0.2.0", "vanilla-colorful": "0.7.2", - "vue": "3.4.27", + "vue": "3.4.29", "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.1", "vue-loader": "17.4.2", - "webpack": "5.91.0", + "webpack": "5.92.0", "webpack-cli": "5.1.4", "wrap-ansi": "9.0.0" }, @@ -65,38 +66,36 @@ "@eslint-community/eslint-plugin-eslint-comments": "4.3.0", "@playwright/test": "1.44.1", "@stoplight/spectral-cli": "6.11.1", - "@stylistic/eslint-plugin-js": "2.1.0", + "@stylistic/eslint-plugin-js": "2.2.1", "@stylistic/stylelint-plugin": "2.1.2", "@typescript-eslint/parser": "7.13.1", - "@vitejs/plugin-vue": "5.0.4", + "@vitejs/plugin-vue": "5.0.5", "eslint": "8.57.0", "eslint-import-resolver-typescript": "3.6.1", "eslint-plugin-array-func": "4.0.0", - "eslint-plugin-github": "5.0.0-2", + "eslint-plugin-github": "5.0.1", "eslint-plugin-i": "2.29.1", - "eslint-plugin-jquery": "1.5.1", - "eslint-plugin-no-jquery": "2.7.0", + "eslint-plugin-no-jquery": "3.0.1", "eslint-plugin-no-use-extend-native": "0.5.0", "eslint-plugin-playwright": "1.6.2", "eslint-plugin-regexp": "2.6.0", "eslint-plugin-sonarjs": "1.0.3", - "eslint-plugin-unicorn": "53.0.0", + "eslint-plugin-unicorn": "54.0.0", "eslint-plugin-vitest": "0.4.1", "eslint-plugin-vitest-globals": "1.5.0", "eslint-plugin-vue": "9.26.0", "eslint-plugin-vue-scoped-css": "2.8.0", "eslint-plugin-wc": "2.1.0", - "happy-dom": "14.11.1", + "happy-dom": "14.12.0", "markdownlint-cli": "0.41.0", "postcss-html": "1.7.0", - "stylelint": "16.6.0", + "stylelint": "16.6.1", "stylelint-declaration-block-no-ignored-properties": "2.8.0", "stylelint-declaration-strict-value": "1.10.4", "stylelint-value-no-unknown-custom-properties": "6.0.1", "svgo": "3.3.2", - "typescript": "5.4.5", - "updates": "16.1.1", - "vite-string-plugin": "1.3.1", + "updates": "16.2.0", + "vite-string-plugin": "1.3.4", "vitest": "1.6.0" }, "browserslist": [ diff --git a/routers/api/actions/actions.go b/routers/api/actions/actions.go index a418b3a1c4538..6f03f290ea535 100644 --- a/routers/api/actions/actions.go +++ b/routers/api/actions/actions.go @@ -11,8 +11,8 @@ import ( "code.gitea.io/gitea/routers/api/actions/runner" ) -func Routes(prefix string) *web.Route { - m := web.NewRoute() +func Routes(prefix string) *web.Router { + m := web.NewRouter() path, handler := ping.NewPingServiceHandler() m.Post(path+"*", http.StripPrefix(prefix, handler).ServeHTTP) diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go index 72a2a26c4761e..da5850589f2e6 100644 --- a/routers/api/actions/artifacts.go +++ b/routers/api/actions/artifacts.go @@ -101,8 +101,8 @@ func init() { }) } -func ArtifactsRoutes(prefix string) *web.Route { - m := web.NewRoute() +func ArtifactsRoutes(prefix string) *web.Router { + m := web.NewRouter() m.Use(ArtifactContexter()) r := artifactRoutes{ @@ -457,7 +457,7 @@ func (ar artifactRoutes) downloadArtifact(ctx *ArtifactContext) { return } - artifactID := ctx.ParamsInt64("artifact_id") + artifactID := ctx.PathParamInt64("artifact_id") artifact, exist, err := db.GetByID[actions.ActionArtifact](ctx, artifactID) if err != nil { log.Error("Error getting artifact: %v", err) diff --git a/routers/api/actions/artifacts_utils.go b/routers/api/actions/artifacts_utils.go index 3517d57f7800d..a4ca5797dc661 100644 --- a/routers/api/actions/artifacts_utils.go +++ b/routers/api/actions/artifacts_utils.go @@ -34,7 +34,7 @@ func validateArtifactName(ctx *ArtifactContext, artifactName string) bool { func validateRunID(ctx *ArtifactContext) (*actions.ActionTask, int64, bool) { task := ctx.ActionTask - runID := ctx.ParamsInt64("run_id") + runID := ctx.PathParamInt64("run_id") if task.Job.RunID != runID { log.Error("Error runID not match") ctx.Error(http.StatusBadRequest, "run-id does not match") @@ -55,7 +55,7 @@ func validateRunIDV4(ctx *ArtifactContext, rawRunID string) (*actions.ActionTask } func validateArtifactHash(ctx *ArtifactContext, artifactName string) bool { - paramHash := ctx.Params("artifact_hash") + paramHash := ctx.PathParam("artifact_hash") // use artifact name to create upload url artifactHash := fmt.Sprintf("%x", md5.Sum([]byte(artifactName))) if paramHash == artifactHash { diff --git a/routers/api/actions/artifactsv4.go b/routers/api/actions/artifactsv4.go index 2ace9f915f0d0..e78ed7a0c2573 100644 --- a/routers/api/actions/artifactsv4.go +++ b/routers/api/actions/artifactsv4.go @@ -129,8 +129,8 @@ func ArtifactV4Contexter() func(next http.Handler) http.Handler { } } -func ArtifactsV4Routes(prefix string) *web.Route { - m := web.NewRoute() +func ArtifactsV4Routes(prefix string) *web.Router { + m := web.NewRouter() r := artifactV4Routes{ prefix: prefix, diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go index 51273198074c7..4b652c9ecc31b 100644 --- a/routers/api/packages/alpine/alpine.go +++ b/routers/api/packages/alpine/alpine.go @@ -73,7 +73,7 @@ func GetRepositoryFile(ctx *context.Context) { pv, &packages_service.PackageFileInfo{ Filename: alpine_service.IndexArchiveFilename, - CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")), + CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture")), }, ) if err != nil { @@ -89,8 +89,8 @@ func GetRepositoryFile(ctx *context.Context) { } func UploadPackageFile(ctx *context.Context) { - branch := strings.TrimSpace(ctx.Params("branch")) - repository := strings.TrimSpace(ctx.Params("repository")) + branch := strings.TrimSpace(ctx.PathParam("branch")) + repository := strings.TrimSpace(ctx.PathParam("repository")) if branch == "" || repository == "" { apiError(ctx, http.StatusBadRequest, "invalid branch or repository") return @@ -182,14 +182,14 @@ func UploadPackageFile(ctx *context.Context) { } func DownloadPackageFile(ctx *context.Context) { - branch := ctx.Params("branch") - repository := ctx.Params("repository") - architecture := ctx.Params("architecture") + branch := ctx.PathParam("branch") + repository := ctx.PathParam("repository") + architecture := ctx.PathParam("architecture") opts := &packages_model.PackageFileSearchOptions{ OwnerID: ctx.Package.Owner.ID, PackageType: packages_model.TypeAlpine, - Query: ctx.Params("filename"), + Query: ctx.PathParam("filename"), CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture), } pfs, _, err := packages_model.SearchFiles(ctx, opts) @@ -230,12 +230,12 @@ func DownloadPackageFile(ctx *context.Context) { } func DeletePackageFile(ctx *context.Context) { - branch, repository, architecture := ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture") + branch, repository, architecture := ctx.PathParam("branch"), ctx.PathParam("repository"), ctx.PathParam("architecture") pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{ OwnerID: ctx.Package.Owner.ID, PackageType: packages_model.TypeAlpine, - Query: ctx.Params("filename"), + Query: ctx.PathParam("filename"), CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture), }) if err != nil { diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 4122f632ffa56..0f42e8f59ebb7 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -74,7 +74,7 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) { } } -func verifyAuth(r *web.Route, authMethods []auth.Method) { +func verifyAuth(r *web.Router, authMethods []auth.Method) { if setting.Service.EnableReverseProxyAuth { authMethods = append(authMethods, &auth.ReverseProxy{}) } @@ -94,8 +94,8 @@ func verifyAuth(r *web.Route, authMethods []auth.Method) { // CommonRoutes provide endpoints for most package managers (except containers - see below) // These are mounted on `/api/packages` (not `/api/v1/packages`) -func CommonRoutes() *web.Route { - r := web.NewRoute() +func CommonRoutes() *web.Router { + r := web.NewRouter() r.Use(context.PackageContexter()) @@ -264,15 +264,15 @@ func CommonRoutes() *web.Route { ) r.Get("/*", func(ctx *context.Context) { - m := downloadPattern.FindStringSubmatch(ctx.Params("*")) + m := downloadPattern.FindStringSubmatch(ctx.PathParam("*")) if len(m) == 0 { ctx.Status(http.StatusNotFound) return } - ctx.SetParams("channel", strings.TrimSuffix(m[1], "/")) - ctx.SetParams("architecture", m[2]) - ctx.SetParams("filename", m[3]) + ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/")) + ctx.SetPathParam("architecture", m[2]) + ctx.SetPathParam("filename", m[3]) switch m[3] { case "repodata.json", "repodata.json.bz2", "current_repodata.json", "current_repodata.json.bz2": @@ -282,14 +282,14 @@ func CommonRoutes() *web.Route { } }) r.Put("/*", reqPackageAccess(perm.AccessModeWrite), func(ctx *context.Context) { - m := uploadPattern.FindStringSubmatch(ctx.Params("*")) + m := uploadPattern.FindStringSubmatch(ctx.PathParam("*")) if len(m) == 0 { ctx.Status(http.StatusNotFound) return } - ctx.SetParams("channel", strings.TrimSuffix(m[1], "/")) - ctx.SetParams("filename", m[2]) + ctx.SetPathParam("channel", strings.TrimSuffix(m[1], "/")) + ctx.SetPathParam("filename", m[2]) conda.UploadPackageFile(ctx) }) @@ -339,11 +339,11 @@ func CommonRoutes() *web.Route { // Manual mapping of routes because the package name contains slashes which chi does not support // https://go.dev/ref/mod#goproxy-protocol r.Get("/*", func(ctx *context.Context) { - path := ctx.Params("*") + path := ctx.PathParam("*") if strings.HasSuffix(path, "/@latest") { - ctx.SetParams("name", path[:len(path)-len("/@latest")]) - ctx.SetParams("version", "latest") + ctx.SetPathParam("name", path[:len(path)-len("/@latest")]) + ctx.SetPathParam("version", "latest") goproxy.PackageVersionMetadata(ctx) return @@ -355,7 +355,7 @@ func CommonRoutes() *web.Route { return } - ctx.SetParams("name", parts[0]) + ctx.SetPathParam("name", parts[0]) // /@v/list if parts[1] == "list" { @@ -365,21 +365,21 @@ func CommonRoutes() *web.Route { // /@v/.zip if strings.HasSuffix(parts[1], ".zip") { - ctx.SetParams("version", parts[1][:len(parts[1])-len(".zip")]) + ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".zip")]) goproxy.DownloadPackageFile(ctx) return } // /@v/.info if strings.HasSuffix(parts[1], ".info") { - ctx.SetParams("version", parts[1][:len(parts[1])-len(".info")]) + ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".info")]) goproxy.PackageVersionMetadata(ctx) return } // /@v/.mod if strings.HasSuffix(parts[1], ".mod") { - ctx.SetParams("version", parts[1][:len(parts[1])-len(".mod")]) + ctx.SetPathParam("version", parts[1][:len(parts[1])-len(".mod")]) goproxy.PackageVersionGoModContent(ctx) return @@ -525,7 +525,7 @@ func CommonRoutes() *web.Route { ) r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) { - path := ctx.Params("*") + path := ctx.PathParam("*") isHead := ctx.Req.Method == "HEAD" isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET" isPut := ctx.Req.Method == "PUT" @@ -533,15 +533,15 @@ func CommonRoutes() *web.Route { m := repoPattern.FindStringSubmatch(path) if len(m) == 2 && isGetHead { - ctx.SetParams("group", strings.Trim(m[1], "/")) + ctx.SetPathParam("group", strings.Trim(m[1], "/")) rpm.GetRepositoryConfig(ctx) return } m = repoFilePattern.FindStringSubmatch(path) if len(m) == 3 && isGetHead { - ctx.SetParams("group", strings.Trim(m[1], "/")) - ctx.SetParams("filename", m[2]) + ctx.SetPathParam("group", strings.Trim(m[1], "/")) + ctx.SetPathParam("filename", m[2]) if isHead { rpm.CheckRepositoryFileExistence(ctx) } else { @@ -556,17 +556,17 @@ func CommonRoutes() *web.Route { if ctx.Written() { return } - ctx.SetParams("group", strings.Trim(m[1], "/")) + ctx.SetPathParam("group", strings.Trim(m[1], "/")) rpm.UploadPackageFile(ctx) return } m = filePattern.FindStringSubmatch(path) if len(m) == 6 && (isGetHead || isDelete) { - ctx.SetParams("group", strings.Trim(m[1], "/")) - ctx.SetParams("name", m[2]) - ctx.SetParams("version", m[3]) - ctx.SetParams("architecture", m[4]) + ctx.SetPathParam("group", strings.Trim(m[1], "/")) + ctx.SetPathParam("name", m[2]) + ctx.SetPathParam("version", m[3]) + ctx.SetPathParam("architecture", m[4]) if isGetHead { rpm.DownloadPackageFile(ctx) } else { @@ -607,13 +607,13 @@ func CommonRoutes() *web.Route { r.Get("", func(ctx *context.Context) { // Can't use normal routes here: https://github.com/go-chi/chi/issues/781 - version := ctx.Params("version") + version := ctx.PathParam("version") if strings.HasSuffix(version, ".zip") { swift.CheckAcceptMediaType(swift.AcceptZip)(ctx) if ctx.Written() { return } - ctx.SetParams("version", version[:len(version)-4]) + ctx.SetPathParam("version", version[:len(version)-4]) swift.DownloadPackageFile(ctx) } else { swift.CheckAcceptMediaType(swift.AcceptJSON)(ctx) @@ -621,7 +621,7 @@ func CommonRoutes() *web.Route { return } if strings.HasSuffix(version, ".json") { - ctx.SetParams("version", version[:len(version)-5]) + ctx.SetPathParam("version", version[:len(version)-5]) } swift.PackageVersionMetadata(ctx) } @@ -651,8 +651,8 @@ func CommonRoutes() *web.Route { // ContainerRoutes provides endpoints that implement the OCI API to serve containers // These have to be mounted on `/v2/...` to comply with the OCI spec: // https://github.com/opencontainers/distribution-spec/blob/main/spec.md -func ContainerRoutes() *web.Route { - r := web.NewRoute() +func ContainerRoutes() *web.Router { + r := web.NewRouter() r.Use(context.PackageContexter()) @@ -700,7 +700,7 @@ func ContainerRoutes() *web.Route { // Manual mapping of routes because {image} can contain slashes which chi does not support r.Methods("HEAD,GET,POST,PUT,PATCH,DELETE", "/*", func(ctx *context.Context) { - path := ctx.Params("*") + path := ctx.PathParam("*") isHead := ctx.Req.Method == "HEAD" isGet := ctx.Req.Method == "GET" isPost := ctx.Req.Method == "POST" @@ -714,7 +714,7 @@ func ContainerRoutes() *web.Route { return } - ctx.SetParams("image", path[:len(path)-14]) + ctx.SetPathParam("image", path[:len(path)-14]) container.VerifyImageName(ctx) if ctx.Written() { return @@ -724,7 +724,7 @@ func ContainerRoutes() *web.Route { return } if isGet && strings.HasSuffix(path, "/tags/list") { - ctx.SetParams("image", path[:len(path)-10]) + ctx.SetPathParam("image", path[:len(path)-10]) container.VerifyImageName(ctx) if ctx.Written() { return @@ -741,13 +741,13 @@ func ContainerRoutes() *web.Route { return } - ctx.SetParams("image", m[1]) + ctx.SetPathParam("image", m[1]) container.VerifyImageName(ctx) if ctx.Written() { return } - ctx.SetParams("uuid", m[2]) + ctx.SetPathParam("uuid", m[2]) if isGet { container.GetUploadBlob(ctx) @@ -762,13 +762,13 @@ func ContainerRoutes() *web.Route { } m = blobsPattern.FindStringSubmatch(path) if len(m) == 3 && (isHead || isGet || isDelete) { - ctx.SetParams("image", m[1]) + ctx.SetPathParam("image", m[1]) container.VerifyImageName(ctx) if ctx.Written() { return } - ctx.SetParams("digest", m[2]) + ctx.SetPathParam("digest", m[2]) if isHead { container.HeadBlob(ctx) @@ -785,13 +785,13 @@ func ContainerRoutes() *web.Route { } m = manifestsPattern.FindStringSubmatch(path) if len(m) == 3 && (isHead || isGet || isPut || isDelete) { - ctx.SetParams("image", m[1]) + ctx.SetPathParam("image", m[1]) container.VerifyImageName(ctx) if ctx.Written() { return } - ctx.SetParams("reference", m[2]) + ctx.SetPathParam("reference", m[2]) if isHead { container.HeadManifest(ctx) diff --git a/routers/api/packages/cargo/cargo.go b/routers/api/packages/cargo/cargo.go index 140e532efd822..3d8407e6b6000 100644 --- a/routers/api/packages/cargo/cargo.go +++ b/routers/api/packages/cargo/cargo.go @@ -55,7 +55,7 @@ func RepositoryConfig(ctx *context.Context) { } func EnumeratePackageVersions(ctx *context.Context) { - p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package")) + p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) @@ -173,11 +173,11 @@ func DownloadPackageFile(ctx *context.Context) { &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeCargo, - Name: ctx.Params("package"), - Version: ctx.Params("version"), + Name: ctx.PathParam("package"), + Version: ctx.PathParam("version"), }, &packages_service.PackageFileInfo{ - Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.Params("package"), ctx.Params("version"))), + Filename: strings.ToLower(fmt.Sprintf("%s-%s.crate", ctx.PathParam("package"), ctx.PathParam("version"))), }, ) if err != nil { @@ -274,7 +274,7 @@ func UnyankPackage(ctx *context.Context) { } func yankPackage(ctx *context.Context, yank bool) { - pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.Params("package"), ctx.Params("version")) + pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeCargo, ctx.PathParam("package"), ctx.PathParam("version")) if err != nil { if err == packages_model.ErrPackageNotExist { apiError(ctx, http.StatusNotFound, err) diff --git a/routers/api/packages/chef/chef.go b/routers/api/packages/chef/chef.go index b49f4e9d0aa8e..b3cdf126977e9 100644 --- a/routers/api/packages/chef/chef.go +++ b/routers/api/packages/chef/chef.go @@ -150,7 +150,7 @@ func EnumeratePackages(ctx *context.Context) { // https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb func PackageMetadata(ctx *context.Context) { - packageName := ctx.Params("name") + packageName := ctx.PathParam("name") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName) if err != nil { @@ -211,8 +211,8 @@ func PackageMetadata(ctx *context.Context) { // https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_show.rb func PackageVersionMetadata(ctx *context.Context) { - packageName := ctx.Params("name") - packageVersion := strings.ReplaceAll(ctx.Params("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?! + packageName := ctx.PathParam("name") + packageVersion := strings.ReplaceAll(ctx.PathParam("version"), "_", ".") // Chef calls this endpoint with "_" instead of "."?! pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, packageName, packageVersion) if err != nil { @@ -325,7 +325,7 @@ func UploadPackage(ctx *context.Context) { // https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_download.rb func DownloadPackage(ctx *context.Context) { - pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name"), ctx.Params("version")) + pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name"), ctx.PathParam("version")) if err != nil { if err == packages_model.ErrPackageNotExist { apiError(ctx, http.StatusNotFound, err) @@ -354,8 +354,8 @@ func DownloadPackage(ctx *context.Context) { // https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb func DeletePackageVersion(ctx *context.Context) { - packageName := ctx.Params("name") - packageVersion := ctx.Params("version") + packageName := ctx.PathParam("name") + packageVersion := ctx.PathParam("version") err := packages_service.RemovePackageVersionByNameAndVersion( ctx, @@ -381,7 +381,7 @@ func DeletePackageVersion(ctx *context.Context) { // https://github.com/chef/chef/blob/main/knife/lib/chef/knife/supermarket_unshare.rb func DeletePackage(ctx *context.Context) { - pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.Params("name")) + pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeChef, ctx.PathParam("name")) if err != nil { apiError(ctx, http.StatusInternalServerError, err) return diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go index a045da40def92..40f72f6484832 100644 --- a/routers/api/packages/composer/composer.go +++ b/routers/api/packages/composer/composer.go @@ -134,8 +134,8 @@ func EnumeratePackages(ctx *context.Context) { // PackageMetadata returns the metadata for a single package // https://packagist.org/apidoc#get-package-data func PackageMetadata(ctx *context.Context) { - vendorName := ctx.Params("vendorname") - projectName := ctx.Params("projectname") + vendorName := ctx.PathParam("vendorname") + projectName := ctx.PathParam("projectname") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeComposer, vendorName+"/"+projectName) if err != nil { @@ -168,11 +168,11 @@ func DownloadPackageFile(ctx *context.Context) { &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeComposer, - Name: ctx.Params("package"), - Version: ctx.Params("version"), + Name: ctx.PathParam("package"), + Version: ctx.PathParam("version"), }, &packages_service.PackageFileInfo{ - Filename: ctx.Params("filename"), + Filename: ctx.PathParam("filename"), }, ) if err != nil { diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go index 07ea3eda34139..7afca2fab18a5 100644 --- a/routers/api/packages/conan/conan.go +++ b/routers/api/packages/conan/conan.go @@ -72,11 +72,11 @@ func baseURL(ctx *context.Context) string { // ExtractPathParameters is a middleware to extract common parameters from path func ExtractPathParameters(ctx *context.Context) { rref, err := conan_module.NewRecipeReference( - ctx.Params("name"), - ctx.Params("version"), - ctx.Params("user"), - ctx.Params("channel"), - ctx.Params("recipe_revision"), + ctx.PathParam("name"), + ctx.PathParam("version"), + ctx.PathParam("user"), + ctx.PathParam("channel"), + ctx.PathParam("recipe_revision"), ) if err != nil { apiError(ctx, http.StatusBadRequest, err) @@ -85,14 +85,14 @@ func ExtractPathParameters(ctx *context.Context) { ctx.Data[recipeReferenceKey] = rref - reference := ctx.Params("package_reference") + reference := ctx.PathParam("package_reference") var pref *conan_module.PackageReference if reference != "" { pref, err = conan_module.NewPackageReference( rref, reference, - ctx.Params("package_revision"), + ctx.PathParam("package_revision"), ) if err != nil { apiError(ctx, http.StatusBadRequest, err) @@ -304,7 +304,7 @@ func uploadFile(ctx *context.Context, fileFilter container.Set[string], fileKey rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference) pref := ctx.Data[packageReferenceKey].(*conan_module.PackageReference) - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") if !fileFilter.Contains(filename) { apiError(ctx, http.StatusBadRequest, nil) return @@ -444,7 +444,7 @@ func DownloadPackageFile(ctx *context.Context) { func downloadFile(ctx *context.Context, fileFilter container.Set[string], fileKey string) { rref := ctx.Data[recipeReferenceKey].(*conan_module.RecipeReference) - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") if !fileFilter.Contains(filename) { apiError(ctx, http.StatusBadRequest, nil) return diff --git a/routers/api/packages/conda/conda.go b/routers/api/packages/conda/conda.go index c7e4544d52d34..7a46681235a34 100644 --- a/routers/api/packages/conda/conda.go +++ b/routers/api/packages/conda/conda.go @@ -66,7 +66,7 @@ func EnumeratePackages(ctx *context.Context) { repoData := &RepoData{ Info: Info{ - Subdir: ctx.Params("architecture"), + Subdir: ctx.PathParam("architecture"), }, Packages: make(map[string]*PackageInfo), PackagesConda: make(map[string]*PackageInfo), @@ -75,7 +75,7 @@ func EnumeratePackages(ctx *context.Context) { pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{ OwnerID: ctx.Package.Owner.ID, - Channel: ctx.Params("channel"), + Channel: ctx.PathParam("channel"), Subdir: repoData.Info.Subdir, }) if err != nil { @@ -151,7 +151,7 @@ func EnumeratePackages(ctx *context.Context) { var w io.Writer = resp - if strings.HasSuffix(ctx.Params("filename"), ".json") { + if strings.HasSuffix(ctx.PathParam("filename"), ".json") { resp.Header().Set("Content-Type", "application/json") } else { resp.Header().Set("Content-Type", "application/x-bzip2") @@ -191,7 +191,7 @@ func UploadPackageFile(ctx *context.Context) { defer buf.Close() var pck *conda_module.Package - if strings.HasSuffix(strings.ToLower(ctx.Params("filename")), ".tar.bz2") { + if strings.HasSuffix(strings.ToLower(ctx.PathParam("filename")), ".tar.bz2") { pck, err = conda_module.ParsePackageBZ2(buf) } else { pck, err = conda_module.ParsePackageConda(buf, buf.Size()) @@ -212,7 +212,7 @@ func UploadPackageFile(ctx *context.Context) { fullName := pck.Name - channel := ctx.Params("channel") + channel := ctx.PathParam("channel") if channel != "" { fullName = channel + "/" + pck.Name } @@ -277,9 +277,9 @@ func UploadPackageFile(ctx *context.Context) { func DownloadPackageFile(ctx *context.Context) { pfs, err := conda_model.SearchFiles(ctx, &conda_model.FileSearchOptions{ OwnerID: ctx.Package.Owner.ID, - Channel: ctx.Params("channel"), - Subdir: ctx.Params("architecture"), - Filename: ctx.Params("filename"), + Channel: ctx.PathParam("channel"), + Subdir: ctx.PathParam("architecture"), + Filename: ctx.PathParam("filename"), }) if err != nil { apiError(ctx, http.StatusInternalServerError, err) diff --git a/routers/api/packages/container/container.go b/routers/api/packages/container/container.go index 5007037beebf4..74a3295f09b3a 100644 --- a/routers/api/packages/container/container.go +++ b/routers/api/packages/container/container.go @@ -131,7 +131,7 @@ func ReqContainerAccess(ctx *context.Context) { // VerifyImageName is a middleware which checks if the image name is allowed func VerifyImageName(ctx *context.Context) { - if !imageNamePattern.MatchString(ctx.Params("image")) { + if !imageNamePattern.MatchString(ctx.PathParam("image")) { apiErrorDefined(ctx, errNameInvalid) } } @@ -216,7 +216,7 @@ func GetRepositoryList(ctx *context.Context) { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#single-post // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks func InitiateUploadBlob(ctx *context.Context) { - image := ctx.Params("image") + image := ctx.PathParam("image") mount := ctx.FormTrim("mount") from := ctx.FormTrim("from") @@ -305,7 +305,7 @@ func InitiateUploadBlob(ctx *context.Context) { // https://docs.docker.com/registry/spec/api/#get-blob-upload func GetUploadBlob(ctx *context.Context) { - uuid := ctx.Params("uuid") + uuid := ctx.PathParam("uuid") upload, err := packages_model.GetBlobUploadByID(ctx, uuid) if err != nil { @@ -326,9 +326,9 @@ func GetUploadBlob(ctx *context.Context) { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks func UploadBlob(ctx *context.Context) { - image := ctx.Params("image") + image := ctx.PathParam("image") - uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid")) + uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid")) if err != nil { if err == packages_model.ErrPackageBlobUploadNotExist { apiErrorDefined(ctx, errBlobUploadUnknown) @@ -371,7 +371,7 @@ func UploadBlob(ctx *context.Context) { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-a-blob-in-chunks func EndUploadBlob(ctx *context.Context) { - image := ctx.Params("image") + image := ctx.PathParam("image") digest := ctx.FormTrim("digest") if digest == "" { @@ -379,7 +379,7 @@ func EndUploadBlob(ctx *context.Context) { return } - uploader, err := container_service.NewBlobUploader(ctx, ctx.Params("uuid")) + uploader, err := container_service.NewBlobUploader(ctx, ctx.PathParam("uuid")) if err != nil { if err == packages_model.ErrPackageBlobUploadNotExist { apiErrorDefined(ctx, errBlobUploadUnknown) @@ -446,7 +446,7 @@ func EndUploadBlob(ctx *context.Context) { // https://docs.docker.com/registry/spec/api/#delete-blob-upload func CancelUploadBlob(ctx *context.Context) { - uuid := ctx.Params("uuid") + uuid := ctx.PathParam("uuid") _, err := packages_model.GetBlobUploadByID(ctx, uuid) if err != nil { @@ -469,7 +469,7 @@ func CancelUploadBlob(ctx *context.Context) { } func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescriptor, error) { - d := ctx.Params("digest") + d := ctx.PathParam("digest") if digest.Digest(d).Validate() != nil { return nil, container_model.ErrContainerBlobNotExist @@ -477,7 +477,7 @@ func getBlobFromContext(ctx *context.Context) (*packages_model.PackageFileDescri return workaroundGetContainerBlob(ctx, &container_model.BlobSearchOptions{ OwnerID: ctx.Package.Owner.ID, - Image: ctx.Params("image"), + Image: ctx.PathParam("image"), Digest: d, }) } @@ -518,14 +518,14 @@ func GetBlob(ctx *context.Context) { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#deleting-blobs func DeleteBlob(ctx *context.Context) { - d := ctx.Params("digest") + d := ctx.PathParam("digest") if digest.Digest(d).Validate() != nil { apiErrorDefined(ctx, errBlobUnknown) return } - if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.Params("image"), d); err != nil { + if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.PathParam("image"), d); err != nil { apiError(ctx, http.StatusInternalServerError, err) return } @@ -537,13 +537,13 @@ func DeleteBlob(ctx *context.Context) { // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests func UploadManifest(ctx *context.Context) { - reference := ctx.Params("reference") + reference := ctx.PathParam("reference") mci := &manifestCreationInfo{ MediaType: ctx.Req.Header.Get("Content-Type"), Owner: ctx.Package.Owner, Creator: ctx.Doer, - Image: ctx.Params("image"), + Image: ctx.PathParam("image"), Reference: reference, IsTagged: digest.Digest(reference).Validate() != nil, } @@ -592,11 +592,11 @@ func UploadManifest(ctx *context.Context) { } func getBlobSearchOptionsFromContext(ctx *context.Context) (*container_model.BlobSearchOptions, error) { - reference := ctx.Params("reference") + reference := ctx.PathParam("reference") opts := &container_model.BlobSearchOptions{ OwnerID: ctx.Package.Owner.ID, - Image: ctx.Params("image"), + Image: ctx.PathParam("image"), IsManifest: true, } @@ -719,7 +719,7 @@ func serveBlob(ctx *context.Context, pfd *packages_model.PackageFileDescriptor) // https://github.com/opencontainers/distribution-spec/blob/main/spec.md#content-discovery func GetTagList(ctx *context.Context) { - image := ctx.Params("image") + image := ctx.PathParam("image") if _, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.TypeContainer, image); err != nil { if err == packages_model.ErrPackageNotExist { diff --git a/routers/api/packages/cran/cran.go b/routers/api/packages/cran/cran.go index f1d616724ac22..8a20072cb6dd2 100644 --- a/routers/api/packages/cran/cran.go +++ b/routers/api/packages/cran/cran.go @@ -28,18 +28,18 @@ func apiError(ctx *context.Context, status int, obj any) { } func EnumerateSourcePackages(ctx *context.Context) { - enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{ + enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{ OwnerID: ctx.Package.Owner.ID, FileType: cran_module.TypeSource, }) } func EnumerateBinaryPackages(ctx *context.Context) { - enumeratePackages(ctx, ctx.Params("format"), &cran_model.SearchOptions{ + enumeratePackages(ctx, ctx.PathParam("format"), &cran_model.SearchOptions{ OwnerID: ctx.Package.Owner.ID, FileType: cran_module.TypeBinary, - Platform: ctx.Params("platform"), - RVersion: ctx.Params("rversion"), + Platform: ctx.PathParam("platform"), + RVersion: ctx.PathParam("rversion"), }) } @@ -225,7 +225,7 @@ func DownloadSourcePackageFile(ctx *context.Context) { downloadPackageFile(ctx, &cran_model.SearchOptions{ OwnerID: ctx.Package.Owner.ID, FileType: cran_module.TypeSource, - Filename: ctx.Params("filename"), + Filename: ctx.PathParam("filename"), }) } @@ -233,9 +233,9 @@ func DownloadBinaryPackageFile(ctx *context.Context) { downloadPackageFile(ctx, &cran_model.SearchOptions{ OwnerID: ctx.Package.Owner.ID, FileType: cran_module.TypeBinary, - Platform: ctx.Params("platform"), - RVersion: ctx.Params("rversion"), - Filename: ctx.Params("filename"), + Platform: ctx.PathParam("platform"), + RVersion: ctx.PathParam("rversion"), + Filename: ctx.PathParam("filename"), }) } diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go index 8c05476cbc3ea..162122ccbdced 100644 --- a/routers/api/packages/debian/debian.go +++ b/routers/api/packages/debian/debian.go @@ -51,10 +51,10 @@ func GetRepositoryFile(ctx *context.Context) { return } - key := ctx.Params("distribution") + key := ctx.PathParam("distribution") - component := ctx.Params("component") - architecture := strings.TrimPrefix(ctx.Params("architecture"), "binary-") + component := ctx.PathParam("component") + architecture := strings.TrimPrefix(ctx.PathParam("architecture"), "binary-") if component != "" && architecture != "" { key += "|" + component + "|" + architecture } @@ -63,7 +63,7 @@ func GetRepositoryFile(ctx *context.Context) { ctx, pv, &packages_service.PackageFileInfo{ - Filename: ctx.Params("filename"), + Filename: ctx.PathParam("filename"), CompositeKey: key, }, ) @@ -87,14 +87,14 @@ func GetRepositoryFileByHash(ctx *context.Context) { return } - algorithm := strings.ToLower(ctx.Params("algorithm")) + algorithm := strings.ToLower(ctx.PathParam("algorithm")) if algorithm == "md5sum" { algorithm = "md5" } pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{ VersionID: pv.ID, - Hash: strings.ToLower(ctx.Params("hash")), + Hash: strings.ToLower(ctx.PathParam("hash")), HashAlgorithm: algorithm, }) if err != nil { @@ -120,8 +120,8 @@ func GetRepositoryFileByHash(ctx *context.Context) { } func UploadPackageFile(ctx *context.Context) { - distribution := strings.TrimSpace(ctx.Params("distribution")) - component := strings.TrimSpace(ctx.Params("component")) + distribution := strings.TrimSpace(ctx.PathParam("distribution")) + component := strings.TrimSpace(ctx.PathParam("component")) if distribution == "" || component == "" { apiError(ctx, http.StatusBadRequest, "invalid distribution or component") return @@ -207,8 +207,8 @@ func UploadPackageFile(ctx *context.Context) { } func DownloadPackageFile(ctx *context.Context) { - name := ctx.Params("name") - version := ctx.Params("version") + name := ctx.PathParam("name") + version := ctx.PathParam("version") s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, @@ -219,8 +219,8 @@ func DownloadPackageFile(ctx *context.Context) { Version: version, }, &packages_service.PackageFileInfo{ - Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.Params("architecture")), - CompositeKey: fmt.Sprintf("%s|%s", ctx.Params("distribution"), ctx.Params("component")), + Filename: fmt.Sprintf("%s_%s_%s.deb", name, version, ctx.PathParam("architecture")), + CompositeKey: fmt.Sprintf("%s|%s", ctx.PathParam("distribution"), ctx.PathParam("component")), }, ) if err != nil { @@ -240,11 +240,11 @@ func DownloadPackageFile(ctx *context.Context) { } func DeletePackageFile(ctx *context.Context) { - distribution := ctx.Params("distribution") - component := ctx.Params("component") - name := ctx.Params("name") - version := ctx.Params("version") - architecture := ctx.Params("architecture") + distribution := ctx.PathParam("distribution") + component := ctx.PathParam("component") + name := ctx.PathParam("name") + version := ctx.PathParam("version") + architecture := ctx.PathParam("architecture") owner := ctx.Package.Owner diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go index e66f3ee676c41..868caf9cf062a 100644 --- a/routers/api/packages/generic/generic.go +++ b/routers/api/packages/generic/generic.go @@ -36,11 +36,11 @@ func DownloadPackageFile(ctx *context.Context) { &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeGeneric, - Name: ctx.Params("packagename"), - Version: ctx.Params("packageversion"), + Name: ctx.PathParam("packagename"), + Version: ctx.PathParam("packageversion"), }, &packages_service.PackageFileInfo{ - Filename: ctx.Params("filename"), + Filename: ctx.PathParam("filename"), }, ) if err != nil { @@ -71,8 +71,8 @@ func isValidFileName(filename string) bool { // UploadPackage uploads the specific generic package. // Duplicated packages get rejected. func UploadPackage(ctx *context.Context) { - packageName := ctx.Params("packagename") - filename := ctx.Params("filename") + packageName := ctx.PathParam("packagename") + filename := ctx.PathParam("filename") if !isValidPackageName(packageName) { apiError(ctx, http.StatusBadRequest, errors.New("invalid package name")) @@ -84,7 +84,7 @@ func UploadPackage(ctx *context.Context) { return } - packageVersion := ctx.Params("packageversion") + packageVersion := ctx.PathParam("packageversion") if packageVersion != strings.TrimSpace(packageVersion) { apiError(ctx, http.StatusBadRequest, errors.New("invalid package version")) return @@ -150,8 +150,8 @@ func DeletePackage(ctx *context.Context) { &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeGeneric, - Name: ctx.Params("packagename"), - Version: ctx.Params("packageversion"), + Name: ctx.PathParam("packagename"), + Version: ctx.PathParam("packageversion"), }, ) if err != nil { @@ -169,12 +169,12 @@ func DeletePackage(ctx *context.Context) { // DeletePackageFile deletes the specific file of a generic package. func DeletePackageFile(ctx *context.Context) { pv, pf, err := func() (*packages_model.PackageVersion, *packages_model.PackageFile, error) { - pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeGeneric, ctx.Params("packagename"), ctx.Params("packageversion")) + pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeGeneric, ctx.PathParam("packagename"), ctx.PathParam("packageversion")) if err != nil { return nil, nil, err } - pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey) + pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.PathParam("filename"), packages_model.EmptyFileKey) if err != nil { return nil, nil, err } diff --git a/routers/api/packages/goproxy/goproxy.go b/routers/api/packages/goproxy/goproxy.go index 56a07dbd43ec8..bde29df73935e 100644 --- a/routers/api/packages/goproxy/goproxy.go +++ b/routers/api/packages/goproxy/goproxy.go @@ -28,7 +28,7 @@ func apiError(ctx *context.Context, status int, obj any) { } func EnumeratePackageVersions(ctx *context.Context) { - pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.Params("name")) + pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeGo, ctx.PathParam("name")) if err != nil { apiError(ctx, http.StatusInternalServerError, err) return @@ -50,7 +50,7 @@ func EnumeratePackageVersions(ctx *context.Context) { } func PackageVersionMetadata(ctx *context.Context) { - pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version")) + pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) @@ -70,7 +70,7 @@ func PackageVersionMetadata(ctx *context.Context) { } func PackageVersionGoModContent(ctx *context.Context) { - pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version")) + pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) @@ -90,7 +90,7 @@ func PackageVersionGoModContent(ctx *context.Context) { } func DownloadPackageFile(ctx *context.Context) { - pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.Params("name"), ctx.Params("version")) + pv, err := resolvePackage(ctx, ctx.Package.Owner.ID, ctx.PathParam("name"), ctx.PathParam("version")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) diff --git a/routers/api/packages/helm/helm.go b/routers/api/packages/helm/helm.go index efdb83ec0e776..cb30a20074e3f 100644 --- a/routers/api/packages/helm/helm.go +++ b/routers/api/packages/helm/helm.go @@ -101,14 +101,14 @@ func Index(ctx *context.Context) { // DownloadPackageFile serves the content of a package func DownloadPackageFile(ctx *context.Context) { - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{ OwnerID: ctx.Package.Owner.ID, Type: packages_model.TypeHelm, Name: packages_model.SearchValue{ ExactMatch: true, - Value: ctx.Params("package"), + Value: ctx.PathParam("package"), }, HasFileWithName: filename, IsInternal: optional.Some(false), diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go index cb15eae682640..1486e83c57db5 100644 --- a/routers/api/packages/maven/maven.go +++ b/routers/api/packages/maven/maven.go @@ -385,7 +385,7 @@ type parameters struct { } func extractPathParameters(ctx *context.Context) (parameters, error) { - parts := strings.Split(ctx.Params("*"), "/") + parts := strings.Split(ctx.PathParam("*"), "/") p := parameters{ Filename: parts[len(parts)-1], diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go index 84acfffae25e2..284723e0d7d0b 100644 --- a/routers/api/packages/npm/npm.go +++ b/routers/api/packages/npm/npm.go @@ -43,8 +43,8 @@ func apiError(ctx *context.Context, status int, obj any) { // packageNameFromParams gets the package name from the url parameters // Variations: /name/, /@scope/name/, /@scope%2Fname/ func packageNameFromParams(ctx *context.Context) string { - scope := ctx.Params("scope") - id := ctx.Params("id") + scope := ctx.PathParam("scope") + id := ctx.PathParam("id") if scope != "" { return fmt.Sprintf("@%s/%s", scope, id) } @@ -82,8 +82,8 @@ func PackageMetadata(ctx *context.Context) { // DownloadPackageFile serves the content of a package func DownloadPackageFile(ctx *context.Context) { packageName := packageNameFromParams(ctx) - packageVersion := ctx.Params("version") - filename := ctx.Params("filename") + packageVersion := ctx.PathParam("version") + filename := ctx.PathParam("filename") s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, @@ -111,7 +111,7 @@ func DownloadPackageFile(ctx *context.Context) { // DownloadPackageFileByName finds the version and serves the contents of a package func DownloadPackageFileByName(ctx *context.Context) { - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") pvs, _, err := packages_model.SearchVersions(ctx, &packages_model.PackageSearchOptions{ OwnerID: ctx.Package.Owner.ID, @@ -254,7 +254,7 @@ func DeletePreview(ctx *context.Context) { // DeletePackageVersion deletes the package version func DeletePackageVersion(ctx *context.Context) { packageName := packageNameFromParams(ctx) - packageVersion := ctx.Params("version") + packageVersion := ctx.PathParam("version") err := packages_service.RemovePackageVersionByNameAndVersion( ctx, @@ -349,7 +349,7 @@ func AddPackageTag(ctx *context.Context) { return } - if err := setPackageTag(ctx, ctx.Params("tag"), pv, false); err != nil { + if err := setPackageTag(ctx, ctx.PathParam("tag"), pv, false); err != nil { if err == errInvalidTagName { apiError(ctx, http.StatusBadRequest, err) return @@ -370,7 +370,7 @@ func DeletePackageTag(ctx *context.Context) { } if len(pvs) != 0 { - if err := setPackageTag(ctx, ctx.Params("tag"), pvs[0], true); err != nil { + if err := setPackageTag(ctx, ctx.PathParam("tag"), pvs[0], true); err != nil { if err == errInvalidTagName { apiError(ctx, http.StatusBadRequest, err) return diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go index 0d7212d7f782f..70b95e6a77406 100644 --- a/routers/api/packages/nuget/nuget.go +++ b/routers/api/packages/nuget/nuget.go @@ -226,7 +226,7 @@ func SearchServiceV3(ctx *context.Context) { // https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-index func RegistrationIndex(ctx *context.Context) { - packageName := ctx.Params("id") + packageName := ctx.PathParam("id") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName) if err != nil { @@ -254,8 +254,8 @@ func RegistrationIndex(ctx *context.Context) { // https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedQueryBuilder.cs func RegistrationLeafV2(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := ctx.Params("version") + packageName := ctx.PathParam("id") + packageVersion := ctx.PathParam("version") pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion) if err != nil { @@ -283,8 +283,8 @@ func RegistrationLeafV2(ctx *context.Context) { // https://docs.microsoft.com/en-us/nuget/api/registration-base-url-resource#registration-leaf func RegistrationLeafV3(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := strings.TrimSuffix(ctx.Params("version"), ".json") + packageName := ctx.PathParam("id") + packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".json") pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName, packageVersion) if err != nil { @@ -381,7 +381,7 @@ func EnumeratePackageVersionsV2Count(ctx *context.Context) { // https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions func EnumeratePackageVersionsV3(ctx *context.Context) { - packageName := ctx.Params("id") + packageName := ctx.PathParam("id") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeNuGet, packageName) if err != nil { @@ -401,9 +401,9 @@ func EnumeratePackageVersionsV3(ctx *context.Context) { // https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec // https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg func DownloadPackageFile(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := ctx.Params("version") - filename := ctx.Params("filename") + packageName := ctx.PathParam("id") + packageVersion := ctx.PathParam("version") + filename := ctx.PathParam("filename") s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, @@ -643,9 +643,9 @@ func processUploadedFile(ctx *context.Context, expectedType nuget_module.Package // https://github.com/dotnet/symstore/blob/main/docs/specs/Simple_Symbol_Query_Protocol.md#request func DownloadSymbolFile(ctx *context.Context) { - filename := ctx.Params("filename") - guid := ctx.Params("guid")[:32] - filename2 := ctx.Params("filename2") + filename := ctx.PathParam("filename") + guid := ctx.PathParam("guid")[:32] + filename2 := ctx.PathParam("filename2") if filename != filename2 { apiError(ctx, http.StatusBadRequest, nil) @@ -685,8 +685,8 @@ func DownloadSymbolFile(ctx *context.Context) { // DeletePackage hard deletes the package // https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#delete-a-package func DeletePackage(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := ctx.Params("version") + packageName := ctx.PathParam("id") + packageVersion := ctx.PathParam("version") err := packages_service.RemovePackageVersionByNameAndVersion( ctx, diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go index f87df52a29aa1..2be27323fd16f 100644 --- a/routers/api/packages/pub/pub.go +++ b/routers/api/packages/pub/pub.go @@ -81,7 +81,7 @@ func baseURL(ctx *context.Context) string { // https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#list-all-versions-of-a-package func EnumeratePackageVersions(ctx *context.Context) { - packageName := ctx.Params("id") + packageName := ctx.PathParam("id") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName) if err != nil { @@ -119,8 +119,8 @@ func EnumeratePackageVersions(ctx *context.Context) { // https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-inspect-a-specific-version-of-a-package func PackageVersionMetadata(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := ctx.Params("version") + packageName := ctx.PathParam("id") + packageVersion := ctx.PathParam("version") pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion) if err != nil { @@ -228,8 +228,8 @@ func UploadPackageFile(ctx *context.Context) { // https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#publishing-packages func FinalizePackage(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := ctx.Params("version") + packageName := ctx.PathParam("id") + packageVersion := ctx.PathParam("version") _, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion) if err != nil { @@ -253,8 +253,8 @@ func FinalizePackage(ctx *context.Context) { // https://github.com/dart-lang/pub/blob/master/doc/repository-spec-v2.md#deprecated-download-a-specific-version-of-a-package func DownloadPackageFile(ctx *context.Context) { - packageName := ctx.Params("id") - packageVersion := strings.TrimSuffix(ctx.Params("version"), ".tar.gz") + packageName := ctx.PathParam("id") + packageVersion := strings.TrimSuffix(ctx.PathParam("version"), ".tar.gz") pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypePub, packageName, packageVersion) if err != nil { diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go index 7824db18235d9..5ea86071a9e64 100644 --- a/routers/api/packages/pypi/pypi.go +++ b/routers/api/packages/pypi/pypi.go @@ -45,7 +45,7 @@ func apiError(ctx *context.Context, status int, obj any) { // PackageMetadata returns the metadata for a single package func PackageMetadata(ctx *context.Context) { - packageName := normalizer.Replace(ctx.Params("id")) + packageName := normalizer.Replace(ctx.PathParam("id")) pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypePyPI, packageName) if err != nil { @@ -76,9 +76,9 @@ func PackageMetadata(ctx *context.Context) { // DownloadPackageFile serves the content of a package func DownloadPackageFile(ctx *context.Context) { - packageName := normalizer.Replace(ctx.Params("id")) - packageVersion := ctx.Params("version") - filename := ctx.Params("filename") + packageName := normalizer.Replace(ctx.PathParam("id")) + packageVersion := ctx.PathParam("version") + filename := ctx.PathParam("filename") s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go index c59366992c365..11d7729eec2d6 100644 --- a/routers/api/packages/rpm/rpm.go +++ b/routers/api/packages/rpm/rpm.go @@ -33,7 +33,7 @@ func apiError(ctx *context.Context, status int, obj any) { // https://dnf.readthedocs.io/en/latest/conf_ref.html func GetRepositoryConfig(ctx *context.Context) { - group := ctx.Params("group") + group := ctx.PathParam("group") var groupParts []string if group != "" { @@ -71,7 +71,7 @@ func CheckRepositoryFileExistence(ctx *context.Context) { return } - pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), ctx.Params("group")) + pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.PathParam("filename"), ctx.PathParam("group")) if err != nil { if errors.Is(err, util.ErrNotExist) { ctx.Status(http.StatusNotFound) @@ -100,8 +100,8 @@ func GetRepositoryFile(ctx *context.Context) { ctx, pv, &packages_service.PackageFileInfo{ - Filename: ctx.Params("filename"), - CompositeKey: ctx.Params("group"), + Filename: ctx.PathParam("filename"), + CompositeKey: ctx.PathParam("group"), }, ) if err != nil { @@ -153,7 +153,7 @@ func UploadPackageFile(ctx *context.Context) { apiError(ctx, http.StatusInternalServerError, err) return } - group := ctx.Params("group") + group := ctx.PathParam("group") _, _, err = packages_service.CreatePackageOrAddFileToExisting( ctx, &packages_service.PackageCreationInfo{ @@ -202,8 +202,8 @@ func UploadPackageFile(ctx *context.Context) { } func DownloadPackageFile(ctx *context.Context) { - name := ctx.Params("name") - version := ctx.Params("version") + name := ctx.PathParam("name") + version := ctx.PathParam("version") s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, @@ -214,8 +214,8 @@ func DownloadPackageFile(ctx *context.Context) { Version: version, }, &packages_service.PackageFileInfo{ - Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.Params("architecture")), - CompositeKey: ctx.Params("group"), + Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.PathParam("architecture")), + CompositeKey: ctx.PathParam("group"), }, ) if err != nil { @@ -231,10 +231,10 @@ func DownloadPackageFile(ctx *context.Context) { } func DeletePackageFile(webctx *context.Context) { - group := webctx.Params("group") - name := webctx.Params("name") - version := webctx.Params("version") - architecture := webctx.Params("architecture") + group := webctx.PathParam("group") + name := webctx.PathParam("name") + version := webctx.PathParam("version") + architecture := webctx.PathParam("architecture") var pd *packages_model.PackageDescriptor diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go index 0a08378b47641..958063e70abcc 100644 --- a/routers/api/packages/rubygems/rubygems.go +++ b/routers/api/packages/rubygems/rubygems.go @@ -95,7 +95,7 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo // ServePackageSpecification serves the compressed Gemspec file of a package func ServePackageSpecification(ctx *context.Context) { - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") if !strings.HasSuffix(filename, ".gemspec.rz") { apiError(ctx, http.StatusNotImplemented, nil) @@ -164,7 +164,7 @@ func ServePackageSpecification(ctx *context.Context) { // DownloadPackageFile serves the content of a package func DownloadPackageFile(ctx *context.Context) { - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") pvs, err := getVersionsByFilename(ctx, filename) if err != nil { @@ -299,7 +299,7 @@ func DeletePackage(ctx *context.Context) { // GetPackageInfo returns a custom text based format for the single rubygem with a line for each version of the rubygem // ref: https://guides.rubygems.org/rubygems-org-compact-index-api/ func GetPackageInfo(ctx *context.Context) { - packageName := ctx.Params("packagename") + packageName := ctx.PathParam("packagename") versions, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeRubyGems, packageName) if err != nil { apiError(ctx, http.StatusInternalServerError, err) diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go index a9da3ea9c2d86..d5d4d4e9d134c 100644 --- a/routers/api/packages/swift/swift.go +++ b/routers/api/packages/swift/swift.go @@ -115,8 +115,8 @@ type EnumeratePackageVersionsResponse struct { // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#41-list-package-releases func EnumeratePackageVersions(ctx *context.Context) { - packageScope := ctx.Params("scope") - packageName := ctx.Params("name") + packageScope := ctx.PathParam("scope") + packageName := ctx.PathParam("name") pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName)) if err != nil { @@ -172,9 +172,9 @@ type PackageVersionMetadataResponse struct { // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-2 func PackageVersionMetadata(ctx *context.Context) { - id := buildPackageID(ctx.Params("scope"), ctx.Params("name")) + id := buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name")) - pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.Params("version")) + pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, id, ctx.PathParam("version")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) @@ -230,9 +230,9 @@ func PackageVersionMetadata(ctx *context.Context) { // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#43-fetch-manifest-for-a-package-release func DownloadManifest(ctx *context.Context) { - packageScope := ctx.Params("scope") - packageName := ctx.Params("name") - packageVersion := ctx.Params("version") + packageScope := ctx.PathParam("scope") + packageName := ctx.PathParam("name") + packageVersion := ctx.PathParam("version") pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(packageScope, packageName), packageVersion) if err != nil { @@ -282,10 +282,10 @@ func DownloadManifest(ctx *context.Context) { // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-6 func UploadPackageFile(ctx *context.Context) { - packageScope := ctx.Params("scope") - packageName := ctx.Params("name") + packageScope := ctx.PathParam("scope") + packageName := ctx.PathParam("name") - v, err := version.NewVersion(ctx.Params("version")) + v, err := version.NewVersion(ctx.PathParam("version")) if !scopePattern.MatchString(packageScope) || !namePattern.MatchString(packageName) || err != nil { apiError(ctx, http.StatusBadRequest, err) @@ -381,7 +381,7 @@ func UploadPackageFile(ctx *context.Context) { // https://github.com/apple/swift-package-manager/blob/main/Documentation/Registry.md#endpoint-4 func DownloadPackageFile(ctx *context.Context) { - pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.Params("scope"), ctx.Params("name")), ctx.Params("version")) + pv, err := packages_model.GetVersionByNameAndVersion(ctx, ctx.Package.Owner.ID, packages_model.TypeSwift, buildPackageID(ctx.PathParam("scope"), ctx.PathParam("name")), ctx.PathParam("version")) if err != nil { if errors.Is(err, util.ErrNotExist) { apiError(ctx, http.StatusNotFound, err) diff --git a/routers/api/packages/vagrant/vagrant.go b/routers/api/packages/vagrant/vagrant.go index 98a81da368ead..1daf2a0527a72 100644 --- a/routers/api/packages/vagrant/vagrant.go +++ b/routers/api/packages/vagrant/vagrant.go @@ -44,7 +44,7 @@ func CheckAuthenticate(ctx *context.Context) { } func CheckBoxAvailable(ctx *context.Context) { - pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name")) + pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name")) if err != nil { apiError(ctx, http.StatusInternalServerError, err) return @@ -101,7 +101,7 @@ func packageDescriptorToMetadata(baseURL string, pd *packages_model.PackageDescr } func EnumeratePackageVersions(ctx *context.Context) { - pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.Params("name")) + pvs, err := packages_model.GetVersionsByPackageName(ctx, ctx.Package.Owner.ID, packages_model.TypeVagrant, ctx.PathParam("name")) if err != nil { apiError(ctx, http.StatusInternalServerError, err) return @@ -136,14 +136,14 @@ func EnumeratePackageVersions(ctx *context.Context) { } func UploadPackageFile(ctx *context.Context) { - boxName := ctx.Params("name") - boxVersion := ctx.Params("version") + boxName := ctx.PathParam("name") + boxVersion := ctx.PathParam("version") _, err := version.NewSemver(boxVersion) if err != nil { apiError(ctx, http.StatusBadRequest, err) return } - boxProvider := ctx.Params("provider") + boxProvider := ctx.PathParam("provider") if !strings.HasSuffix(boxProvider, ".box") { apiError(ctx, http.StatusBadRequest, err) return @@ -222,11 +222,11 @@ func DownloadPackageFile(ctx *context.Context) { &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeVagrant, - Name: ctx.Params("name"), - Version: ctx.Params("version"), + Name: ctx.PathParam("name"), + Version: ctx.PathParam("version"), }, &packages_service.PackageFileInfo{ - Filename: ctx.Params("provider"), + Filename: ctx.PathParam("provider"), }, ) if err != nil { diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go index a4708fe0326e6..613d123494223 100644 --- a/routers/api/v1/admin/adopt.go +++ b/routers/api/v1/admin/adopt.go @@ -80,8 +80,8 @@ func AdoptRepository(ctx *context.APIContext) { // "$ref": "#/responses/notFound" // "403": // "$ref": "#/responses/forbidden" - ownerName := ctx.Params(":username") - repoName := ctx.Params(":reponame") + ownerName := ctx.PathParam(":username") + repoName := ctx.PathParam(":reponame") ctxUser, err := user_model.GetUserByName(ctx, ownerName) if err != nil { @@ -142,8 +142,8 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) { // "$ref": "#/responses/empty" // "403": // "$ref": "#/responses/forbidden" - ownerName := ctx.Params(":username") - repoName := ctx.Params(":reponame") + ownerName := ctx.PathParam(":username") + repoName := ctx.PathParam(":reponame") ctxUser, err := user_model.GetUserByName(ctx, ownerName) if err != nil { diff --git a/routers/api/v1/admin/cron.go b/routers/api/v1/admin/cron.go index e1ca6048c930b..fba9d33f25f62 100644 --- a/routers/api/v1/admin/cron.go +++ b/routers/api/v1/admin/cron.go @@ -74,7 +74,7 @@ func PostCronTask(ctx *context.APIContext) { // "$ref": "#/responses/empty" // "404": // "$ref": "#/responses/notFound" - task := cron.GetTask(ctx.Params(":task")) + task := cron.GetTask(ctx.PathParam(":task")) if task == nil { ctx.NotFound() return diff --git a/routers/api/v1/admin/email.go b/routers/api/v1/admin/email.go index ba963e9f69d9a..6fe418249ba17 100644 --- a/routers/api/v1/admin/email.go +++ b/routers/api/v1/admin/email.go @@ -38,7 +38,7 @@ func GetAllEmails(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) emails, maxResults, err := user_model.SearchEmails(ctx, &user_model.SearchEmailOptions{ - Keyword: ctx.Params(":email"), + Keyword: ctx.PathParam(":email"), ListOptions: listOptions, }) if err != nil { @@ -82,6 +82,6 @@ func SearchEmail(ctx *context.APIContext) { // "403": // "$ref": "#/responses/forbidden" - ctx.SetParams(":email", ctx.FormTrim("q")) + ctx.SetPathParam(":email", ctx.FormTrim("q")) GetAllEmails(ctx) } diff --git a/routers/api/v1/admin/hooks.go b/routers/api/v1/admin/hooks.go index 4c168b55bf183..fa60836b7e790 100644 --- a/routers/api/v1/admin/hooks.go +++ b/routers/api/v1/admin/hooks.go @@ -73,7 +73,7 @@ func GetHook(ctx *context.APIContext) { // "200": // "$ref": "#/responses/Hook" - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -142,7 +142,7 @@ func EditHook(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.EditHookOption) // TODO in body params - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") utils.EditSystemHook(ctx, form, hookID) } @@ -164,7 +164,7 @@ func DeleteHook(ctx *context.APIContext) { // "204": // "$ref": "#/responses/empty" - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil { if errors.Is(err, util.ErrNotExist) { ctx.NotFound() diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index be907805d60f0..3e2fefc6da234 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -373,7 +373,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.ParamsInt64(":id")); err != nil { + if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.PathParamInt64(":id")); err != nil { if asymkey_model.IsErrKeyNotExist(err) { ctx.NotFound() } else if asymkey_model.IsErrKeyAccessDenied(err) { diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 5363489939083..be67ec1695b3b 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -136,8 +136,8 @@ func sudo() func(ctx *context.APIContext) { func repoAssignment() func(ctx *context.APIContext) { return func(ctx *context.APIContext) { - userName := ctx.Params("username") - repoName := ctx.Params("reponame") + userName := ctx.PathParam("username") + repoName := ctx.PathParam("reponame") var ( owner *user_model.User @@ -555,12 +555,12 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) { var err error if assignOrg { - ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.Params(":org")) + ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.PathParam(":org")) if err != nil { if organization.IsErrOrgNotExist(err) { - redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.Params(":org")) + redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.PathParam(":org")) if err == nil { - context.RedirectToUser(ctx.Base, ctx.Params(":org"), redirectUserID) + context.RedirectToUser(ctx.Base, ctx.PathParam(":org"), redirectUserID) } else if user_model.IsErrUserRedirectNotExist(err) { ctx.NotFound("GetOrgByName", err) } else { @@ -575,7 +575,7 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) { } if assignTeam { - ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.ParamsInt64(":teamid")) + ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.PathParamInt64(":teamid")) if err != nil { if organization.IsErrTeamNotExist(err) { ctx.NotFound() @@ -812,8 +812,8 @@ func checkDeprecatedAuthMethods(ctx *context.APIContext) { } // Routes registers all v1 APIs routes to web application. -func Routes() *web.Route { - m := web.NewRoute() +func Routes() *web.Router { + m := web.NewRouter() m.Use(securityHeaders()) if setting.CORSConfig.Enabled { @@ -837,7 +837,7 @@ func Routes() *web.Route { })) addActionsRoutes := func( - m *web.Route, + m *web.Router, reqChecker func(ctx *context.APIContext), act actions.API, ) { diff --git a/routers/api/v1/misc/gitignore.go b/routers/api/v1/misc/gitignore.go index dffd771752e16..b0bf00a921f88 100644 --- a/routers/api/v1/misc/gitignore.go +++ b/routers/api/v1/misc/gitignore.go @@ -44,7 +44,7 @@ func GetGitignoreTemplateInfo(ctx *context.APIContext) { // "$ref": "#/responses/GitignoreTemplateInfo" // "404": // "$ref": "#/responses/notFound" - name := util.PathJoinRelX(ctx.Params("name")) + name := util.PathJoinRelX(ctx.PathParam("name")) text, err := options.Gitignore(name) if err != nil { diff --git a/routers/api/v1/misc/label_templates.go b/routers/api/v1/misc/label_templates.go index cc11f376262c5..f105b4c684553 100644 --- a/routers/api/v1/misc/label_templates.go +++ b/routers/api/v1/misc/label_templates.go @@ -48,7 +48,7 @@ func GetLabelTemplate(ctx *context.APIContext) { // "$ref": "#/responses/LabelTemplateInfo" // "404": // "$ref": "#/responses/notFound" - name := util.PathJoinRelX(ctx.Params("name")) + name := util.PathJoinRelX(ctx.PathParam("name")) labels, err := repo_module.LoadTemplateLabelsByDisplayName(name) if err != nil { diff --git a/routers/api/v1/misc/licenses.go b/routers/api/v1/misc/licenses.go index 2a980f5084d36..d99b276232d41 100644 --- a/routers/api/v1/misc/licenses.go +++ b/routers/api/v1/misc/licenses.go @@ -55,7 +55,7 @@ func GetLicenseTemplateInfo(ctx *context.APIContext) { // "$ref": "#/responses/LicenseTemplateInfo" // "404": // "$ref": "#/responses/notFound" - name := util.PathJoinRelX(ctx.Params("name")) + name := util.PathJoinRelX(ctx.PathParam("name")) text, err := options.License(name) if err != nil { diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go index 8e12d359cb315..0761e684a3f9c 100644 --- a/routers/api/v1/notify/threads.go +++ b/routers/api/v1/notify/threads.go @@ -101,7 +101,7 @@ func ReadThread(ctx *context.APIContext) { } func getThread(ctx *context.APIContext) *activities_model.Notification { - n, err := activities_model.GetNotificationByID(ctx, ctx.ParamsInt64(":id")) + n, err := activities_model.GetNotificationByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if db.IsErrNotExist(err) { ctx.Error(http.StatusNotFound, "GetNotificationByID", err) diff --git a/routers/api/v1/org/action.go b/routers/api/v1/org/action.go index 03a1fa8ccc368..199ee7d7773b9 100644 --- a/routers/api/v1/org/action.go +++ b/routers/api/v1/org/action.go @@ -106,7 +106,7 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption) - _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Org.Organization.ID, 0, ctx.Params("secretname"), opt.Data) + _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("secretname"), opt.Data) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err) @@ -153,7 +153,7 @@ func (Action) DeleteSecret(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - err := secret_service.DeleteSecretByName(ctx, ctx.Org.Organization.ID, 0, ctx.Params("secretname")) + err := secret_service.DeleteSecretByName(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("secretname")) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteSecret", err) @@ -269,7 +269,7 @@ func (Action) GetVariable(ctx *context.APIContext) { v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ctx.Org.Organization.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -320,7 +320,7 @@ func (Action) DeleteVariable(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := actions_service.DeleteVariableByName(ctx, ctx.Org.Organization.ID, 0, ctx.Params("variablename")); err != nil { + if err := actions_service.DeleteVariableByName(ctx, ctx.Org.Organization.ID, 0, ctx.PathParam("variablename")); err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err) } else if errors.Is(err, util.ErrNotExist) { @@ -371,7 +371,7 @@ func (Action) CreateVariable(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateVariableOption) ownerID := ctx.Org.Organization.ID - variableName := ctx.Params("variablename") + variableName := ctx.PathParam("variablename") v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ownerID, @@ -436,7 +436,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) { v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ctx.Org.Organization.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -448,7 +448,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) { } if opt.Name == "" { - opt.Name = ctx.Params("variablename") + opt.Name = ctx.PathParam("variablename") } if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil { if errors.Is(err, util.ErrInvalidArgument) { diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go index c1dc0519ea1eb..df82f4e5a2b38 100644 --- a/routers/api/v1/org/hook.go +++ b/routers/api/v1/org/hook.go @@ -71,7 +71,7 @@ func GetHook(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.ParamsInt64("id")) + hook, err := utils.GetOwnerHook(ctx, ctx.ContextUser.ID, ctx.PathParamInt64("id")) if err != nil { return } @@ -152,7 +152,7 @@ func EditHook(ctx *context.APIContext) { ctx, ctx.ContextUser, web.GetForm(ctx).(*api.EditHookOption), - ctx.ParamsInt64("id"), + ctx.PathParamInt64("id"), ) } @@ -184,6 +184,6 @@ func DeleteHook(ctx *context.APIContext) { utils.DeleteOwnerHook( ctx, ctx.ContextUser, - ctx.ParamsInt64("id"), + ctx.PathParamInt64("id"), ) } diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go index b5ec54ccf4e2c..24ee4ed642302 100644 --- a/routers/api/v1/org/label.go +++ b/routers/api/v1/org/label.go @@ -139,7 +139,7 @@ func GetLabel(ctx *context.APIContext) { label *issues_model.Label err error ) - strID := ctx.Params(":id") + strID := ctx.PathParam(":id") if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil { label, err = issues_model.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID) } else { @@ -190,7 +190,7 @@ func EditLabel(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.EditLabelOption) - l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id")) + l, err := issues_model.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrOrgLabelNotExist(err) { ctx.NotFound() @@ -249,7 +249,7 @@ func DeleteLabel(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id")); err != nil { + if err := issues_model.DeleteLabel(ctx, ctx.Org.Organization.ID, ctx.PathParamInt64(":id")); err != nil { ctx.Error(http.StatusInternalServerError, "DeleteLabel", err) return } diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 015af774e34e9..c55837ff44fd4 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -453,7 +453,7 @@ func GetTeamMember(ctx *context.APIContext) { if ctx.Written() { return } - teamID := ctx.ParamsInt64("teamid") + teamID := ctx.PathParamInt64("teamid") isTeamMember, err := organization.IsUserInTeams(ctx, u.ID, []int64{teamID}) if err != nil { ctx.Error(http.StatusInternalServerError, "IsUserInTeams", err) @@ -645,7 +645,7 @@ func GetTeamRepo(ctx *context.APIContext) { // getRepositoryByParams get repository by a team's organization ID and repo name func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository { - repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.Params(":reponame")) + repo, err := repo_model.GetRepositoryByName(ctx, ctx.Org.Team.OrgID, ctx.PathParam(":reponame")) if err != nil { if repo_model.IsErrRepoNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index f6656d89c634f..48ba35ac21175 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -122,7 +122,7 @@ func (Action) CreateOrUpdateSecret(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption) - _, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.Params("secretname"), opt.Data) + _, created, err := secret_service.CreateOrUpdateSecret(ctx, owner.ID, repo.ID, ctx.PathParam("secretname"), opt.Data) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err) @@ -177,7 +177,7 @@ func (Action) DeleteSecret(ctx *context.APIContext) { owner := ctx.Repo.Owner repo := ctx.Repo.Repository - err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.Params("secretname")) + err := secret_service.DeleteSecretByName(ctx, owner.ID, repo.ID, ctx.PathParam("secretname")) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteSecret", err) @@ -224,7 +224,7 @@ func (Action) GetVariable(ctx *context.APIContext) { // "$ref": "#/responses/notFound" v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ RepoID: ctx.Repo.Repository.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -280,7 +280,7 @@ func (Action) DeleteVariable(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := actions_service.DeleteVariableByName(ctx, 0, ctx.Repo.Repository.ID, ctx.Params("variablename")); err != nil { + if err := actions_service.DeleteVariableByName(ctx, 0, ctx.Repo.Repository.ID, ctx.PathParam("variablename")); err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err) } else if errors.Is(err, util.ErrNotExist) { @@ -334,7 +334,7 @@ func (Action) CreateVariable(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateVariableOption) repoID := ctx.Repo.Repository.ID - variableName := ctx.Params("variablename") + variableName := ctx.PathParam("variablename") v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ RepoID: repoID, @@ -402,7 +402,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) { v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ RepoID: ctx.Repo.Repository.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -414,7 +414,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) { } if opt.Name == "" { - opt.Name = ctx.Params("variablename") + opt.Name = ctx.PathParam("variablename") } if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil { if errors.Is(err, util.ErrInvalidArgument) { diff --git a/routers/api/v1/repo/blob.go b/routers/api/v1/repo/blob.go index 3b116666ead78..f38086954b710 100644 --- a/routers/api/v1/repo/blob.go +++ b/routers/api/v1/repo/blob.go @@ -41,7 +41,7 @@ func GetBlob(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params("sha") + sha := ctx.PathParam("sha") if len(sha) == 0 { ctx.Error(http.StatusBadRequest, "", "sha not provided") return diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index baab486e522fc..652fcd94419a2 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -56,7 +56,7 @@ func GetBranch(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - branchName := ctx.Params("*") + branchName := ctx.PathParam("*") branch, err := ctx.Repo.GitRepo.GetBranch(branchName) if err != nil { @@ -131,7 +131,7 @@ func DeleteBranch(ctx *context.APIContext) { return } - branchName := ctx.Params("*") + branchName := ctx.PathParam("*") if ctx.Repo.Repository.IsEmpty { ctx.Error(http.StatusForbidden, "", "Git Repository is empty.") @@ -426,7 +426,7 @@ func GetBranchProtection(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repo := ctx.Repo.Repository - bpName := ctx.Params(":name") + bpName := ctx.PathParam(":name") bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err) @@ -724,7 +724,7 @@ func EditBranchProtection(ctx *context.APIContext) { // "$ref": "#/responses/repoArchivedError" form := web.GetForm(ctx).(*api.EditBranchProtectionOption) repo := ctx.Repo.Repository - bpName := ctx.Params(":name") + bpName := ctx.PathParam(":name") protectBranch, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err) @@ -992,7 +992,7 @@ func DeleteBranchProtection(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repo := ctx.Repo.Repository - bpName := ctx.Params(":name") + bpName := ctx.PathParam(":name") bp, err := git_model.GetProtectedBranchRuleByName(ctx, repo.ID, bpName) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err) diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go index 4ce14f7d01837..39c9ba527dfae 100644 --- a/routers/api/v1/repo/collaborators.go +++ b/routers/api/v1/repo/collaborators.go @@ -102,7 +102,7 @@ func IsCollaborator(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - user, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator")) + user, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) @@ -162,7 +162,7 @@ func AddCollaborator(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.AddCollaboratorOption) - collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator")) + collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) @@ -227,7 +227,7 @@ func DeleteCollaborator(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator")) + collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) @@ -275,12 +275,12 @@ func GetRepoPermissions(ctx *context.APIContext) { // "403": // "$ref": "#/responses/forbidden" - if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.Params(":collaborator") && !ctx.IsUserRepoAdmin() { + if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.PathParam(":collaborator") && !ctx.IsUserRepoAdmin() { ctx.Error(http.StatusForbidden, "User", "Only admins can query all permissions, repo admins can query all repo permissions, collaborators can query only their own") return } - collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator")) + collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam(":collaborator")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.Error(http.StatusNotFound, "GetUserByName", err) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index d06a3b4e49a50..d33be9d80a807 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -63,7 +63,7 @@ func GetSingleCommit(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params(":sha") + sha := ctx.PathParam(":sha") if !git.IsValidRefPattern(sha) { ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha)) return @@ -312,8 +312,8 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { // "$ref": "#/responses/string" // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params(":sha") - diffType := git.RawDiffType(ctx.Params(":diffType")) + sha := ctx.PathParam(":sha") + diffType := git.RawDiffType(ctx.PathParam(":diffType")) if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, diffType, ctx.Resp); err != nil { if git.IsErrNotExist(err) { @@ -354,7 +354,7 @@ func GetCommitPullRequest(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.Params(":sha")) + pr, err := issues_model.GetPullRequestByMergedCommit(ctx, ctx.Repo.Repository.ID, ctx.PathParam(":sha")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.Error(http.StatusNotFound, "GetPullRequestByMergedCommit", err) diff --git a/routers/api/v1/repo/compare.go b/routers/api/v1/repo/compare.go index 429145c714800..38e5330b3acb8 100644 --- a/routers/api/v1/repo/compare.go +++ b/routers/api/v1/repo/compare.go @@ -53,7 +53,7 @@ func CompareDiff(ctx *context.APIContext) { defer gitRepo.Close() } - infoPath := ctx.Params("*") + infoPath := ctx.PathParam("*") infos := []string{ctx.Repo.Repository.DefaultBranch, ctx.Repo.Repository.DefaultBranch} if infoPath != "" { infos = strings.SplitN(infoPath, "...", 2) diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 6ecdc1ff67846..42483291fcb33 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -294,7 +294,7 @@ func GetArchive(ctx *context.APIContext) { } func archiveDownload(ctx *context.APIContext) { - uri := ctx.Params("*") + uri := ctx.PathParam("*") aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri) if err != nil { if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) { @@ -393,7 +393,7 @@ func GetEditorconfig(ctx *context.APIContext) { return } - fileName := ctx.Params("filename") + fileName := ctx.PathParam("filename") def, err := ec.GetDefinitionForFilename(fileName) if def == nil { ctx.NotFound(err) @@ -577,7 +577,7 @@ func CreateFile(ctx *context.APIContext) { Files: []*files_service.ChangeRepoFile{ { Operation: "create", - TreePath: ctx.Params("*"), + TreePath: ctx.PathParam("*"), ContentReader: contentReader, }, }, @@ -681,7 +681,7 @@ func UpdateFile(ctx *context.APIContext) { ContentReader: contentReader, SHA: apiOpts.SHA, FromTreePath: apiOpts.FromPath, - TreePath: ctx.Params("*"), + TreePath: ctx.PathParam("*"), }, }, Message: apiOpts.Message, @@ -840,7 +840,7 @@ func DeleteFile(ctx *context.APIContext) { { Operation: "delete", SHA: apiOpts.SHA, - TreePath: ctx.Params("*"), + TreePath: ctx.PathParam("*"), }, }, Message: apiOpts.Message, @@ -935,7 +935,7 @@ func GetContents(ctx *context.APIContext) { return } - treePath := ctx.Params("*") + treePath := ctx.PathParam("*") ref := ctx.FormTrim("ref") if fileList, err := files_service.GetContentsOrList(ctx, ctx.Repo.Repository, treePath, ref); err != nil { diff --git a/routers/api/v1/repo/git_hook.go b/routers/api/v1/repo/git_hook.go index 26ae84d08d339..0887a90096f5a 100644 --- a/routers/api/v1/repo/git_hook.go +++ b/routers/api/v1/repo/git_hook.go @@ -79,7 +79,7 @@ func GetGitHook(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - hookID := ctx.Params(":id") + hookID := ctx.PathParam(":id") hook, err := ctx.Repo.GitRepo.GetHook(hookID) if err != nil { if err == git.ErrNotValidHook { @@ -126,7 +126,7 @@ func EditGitHook(ctx *context.APIContext) { // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.EditGitHookOption) - hookID := ctx.Params(":id") + hookID := ctx.PathParam(":id") hook, err := ctx.Repo.GitRepo.GetHook(hookID) if err != nil { if err == git.ErrNotValidHook { @@ -175,7 +175,7 @@ func DeleteGitHook(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - hookID := ctx.Params(":id") + hookID := ctx.PathParam(":id") hook, err := ctx.Repo.GitRepo.GetHook(hookID) if err != nil { if err == git.ErrNotValidHook { diff --git a/routers/api/v1/repo/git_ref.go b/routers/api/v1/repo/git_ref.go index 0fa58425b8526..1743c0fc20d1d 100644 --- a/routers/api/v1/repo/git_ref.go +++ b/routers/api/v1/repo/git_ref.go @@ -71,7 +71,7 @@ func GetGitRefs(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - getGitRefsInternal(ctx, ctx.Params("*")) + getGitRefsInternal(ctx, ctx.PathParam("*")) } func getGitRefsInternal(ctx *context.APIContext, filter string) { diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index ffd2313591b10..9ef57da1b98fd 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -109,7 +109,7 @@ func GetHook(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repo := ctx.Repo - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") hook, err := utils.GetRepoHook(ctx, repo.Repository.ID, hookID) if err != nil { return @@ -168,7 +168,7 @@ func TestHook(ctx *context.APIContext) { ref = r } - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") hook, err := utils.GetRepoHook(ctx, ctx.Repo.Repository.ID, hookID) if err != nil { return @@ -263,7 +263,7 @@ func EditHook(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.EditHookOption) - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") utils.EditRepoHook(ctx, form, hookID) } @@ -296,7 +296,7 @@ func DeleteHook(ctx *context.APIContext) { // "$ref": "#/responses/empty" // "404": // "$ref": "#/responses/notFound" - if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { + if err := webhook.DeleteWebhookByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")); err != nil { if webhook.IsErrWebhookNotExist(err) { ctx.NotFound() } else { diff --git a/routers/api/v1/repo/hook_test.go b/routers/api/v1/repo/hook_test.go index 37cf61c1edf2d..c2f3a972ef6fc 100644 --- a/routers/api/v1/repo/hook_test.go +++ b/routers/api/v1/repo/hook_test.go @@ -18,7 +18,7 @@ func TestTestHook(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index ddfc36f17dffb..108504ebb4021 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -599,7 +599,7 @@ func GetIssue(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -779,7 +779,7 @@ func EditIssue(ctx *context.APIContext) { // "$ref": "#/responses/error" form := web.GetForm(ctx).(*api.EditIssueOption) - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -942,7 +942,7 @@ func DeleteIssue(ctx *context.APIContext) { // "$ref": "#/responses/forbidden" // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound(err) @@ -998,7 +998,7 @@ func UpdateIssueDeadline(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.EditDeadlineOption) - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/issue_attachment.go b/routers/api/v1/repo/issue_attachment.go index ef846a43a346e..27c7af22823a7 100644 --- a/routers/api/v1/repo/issue_attachment.go +++ b/routers/api/v1/repo/issue_attachment.go @@ -320,7 +320,7 @@ func DeleteIssueAttachment(ctx *context.APIContext) { } func getIssueFromContext(ctx *context.APIContext) *issues_model.Issue { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64("index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index")) if err != nil { ctx.NotFoundOrServerError("GetIssueByIndex", issues_model.IsErrIssueNotExist, err) return nil @@ -345,7 +345,7 @@ func getIssueAttachmentSafeWrite(ctx *context.APIContext) *repo_model.Attachment } func getIssueAttachmentSafeRead(ctx *context.APIContext, issue *issues_model.Issue) *repo_model.Attachment { - attachment, err := repo_model.GetAttachmentByID(ctx, ctx.ParamsInt64("attachment_id")) + attachment, err := repo_model.GetAttachmentByID(ctx, ctx.PathParamInt64("attachment_id")) if err != nil { ctx.NotFoundOrServerError("GetAttachmentByID", repo_model.IsErrAttachmentNotExist, err) return nil diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index 910cc1ce7456b..f9b5aa816bc96 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -68,7 +68,7 @@ func ListIssueComments(ctx *context.APIContext) { ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err) return } - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { ctx.Error(http.StatusInternalServerError, "GetRawIssueByIndex", err) return @@ -172,7 +172,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) { ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err) return } - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { ctx.Error(http.StatusInternalServerError, "GetRawIssueByIndex", err) return @@ -380,7 +380,7 @@ func CreateIssueComment(ctx *context.APIContext) { // "$ref": "#/responses/repoArchivedError" form := web.GetForm(ctx).(*api.CreateIssueCommentOption) - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err) return @@ -445,7 +445,7 @@ func GetIssueComment(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrCommentNotExist(err) { ctx.NotFound(err) @@ -579,7 +579,7 @@ func EditIssueCommentDeprecated(ctx *context.APIContext) { } func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrCommentNotExist(err) { ctx.NotFound(err) @@ -696,7 +696,7 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) { } func deleteIssueComment(ctx *context.APIContext) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrCommentNotExist(err) { ctx.NotFound(err) diff --git a/routers/api/v1/repo/issue_comment_attachment.go b/routers/api/v1/repo/issue_comment_attachment.go index 1ec758ec2ce8f..0863ebd182c8b 100644 --- a/routers/api/v1/repo/issue_comment_attachment.go +++ b/routers/api/v1/repo/issue_comment_attachment.go @@ -331,7 +331,7 @@ func DeleteIssueCommentAttachment(ctx *context.APIContext) { } func getIssueCommentSafe(ctx *context.APIContext) *issues_model.Comment { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64("id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64("id")) if err != nil { ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err) return nil @@ -376,7 +376,7 @@ func canUserWriteIssueCommentAttachment(ctx *context.APIContext, comment *issues } func getIssueCommentAttachmentSafeRead(ctx *context.APIContext, comment *issues_model.Comment) *repo_model.Attachment { - attachment, err := repo_model.GetAttachmentByID(ctx, ctx.ParamsInt64("attachment_id")) + attachment, err := repo_model.GetAttachmentByID(ctx, ctx.PathParamInt64("attachment_id")) if err != nil { ctx.NotFoundOrServerError("GetAttachmentByID", repo_model.IsErrAttachmentNotExist, err) return nil diff --git a/routers/api/v1/repo/issue_dependency.go b/routers/api/v1/repo/issue_dependency.go index c40e92c01bb72..712c71a6823ba 100644 --- a/routers/api/v1/repo/issue_dependency.go +++ b/routers/api/v1/repo/issue_dependency.go @@ -61,7 +61,7 @@ func GetIssueDependencies(ctx *context.APIContext) { return } - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound("IsErrIssueNotExist", err) @@ -499,7 +499,7 @@ func RemoveIssueBlocking(ctx *context.APIContext) { } func getParamsIssue(ctx *context.APIContext) *issues_model.Issue { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound("IsErrIssueNotExist", err) diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go index 413693c5ede9e..2f5ea8931b148 100644 --- a/routers/api/v1/repo/issue_label.go +++ b/routers/api/v1/repo/issue_label.go @@ -47,7 +47,7 @@ func ListIssueLabels(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -163,7 +163,7 @@ func DeleteIssueLabel(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -178,7 +178,7 @@ func DeleteIssueLabel(ctx *context.APIContext) { return } - label, err := issues_model.GetLabelByID(ctx, ctx.ParamsInt64(":id")) + label, err := issues_model.GetLabelByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrLabelNotExist(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) @@ -285,7 +285,7 @@ func ClearIssueLabels(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -309,7 +309,7 @@ func ClearIssueLabels(ctx *context.APIContext) { } func prepareForReplaceOrAdd(ctx *context.APIContext, form api.IssueLabelsOption) (*issues_model.Issue, []*issues_model.Label, error) { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/issue_pin.go b/routers/api/v1/repo/issue_pin.go index af3e06332ade1..0ef9033291591 100644 --- a/routers/api/v1/repo/issue_pin.go +++ b/routers/api/v1/repo/issue_pin.go @@ -41,7 +41,7 @@ func PinIssue(ctx *context.APIContext) { // "$ref": "#/responses/forbidden" // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -98,7 +98,7 @@ func UnpinIssue(ctx *context.APIContext) { // "$ref": "#/responses/forbidden" // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -159,7 +159,7 @@ func MoveIssuePin(ctx *context.APIContext) { // "$ref": "#/responses/forbidden" // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -169,7 +169,7 @@ func MoveIssuePin(ctx *context.APIContext) { return } - err = issue.MovePin(ctx, int(ctx.ParamsInt64(":position"))) + err = issue.MovePin(ctx, int(ctx.PathParamInt64(":position"))) if err != nil { ctx.Error(http.StatusInternalServerError, "MovePin", err) return diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go index 3ff3d19f13efc..8d43cd518bcc3 100644 --- a/routers/api/v1/repo/issue_reaction.go +++ b/routers/api/v1/repo/issue_reaction.go @@ -51,7 +51,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrCommentNotExist(err) { ctx.NotFound(err) @@ -188,7 +188,7 @@ func DeleteIssueCommentReaction(ctx *context.APIContext) { } func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrCommentNotExist(err) { ctx.NotFound(err) @@ -295,7 +295,7 @@ func GetIssueReactions(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -419,7 +419,7 @@ func DeleteIssueReaction(ctx *context.APIContext) { } func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) { - issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/issue_stopwatch.go b/routers/api/v1/repo/issue_stopwatch.go index d9054e8f77573..4605ae211030b 100644 --- a/routers/api/v1/repo/issue_stopwatch.go +++ b/routers/api/v1/repo/issue_stopwatch.go @@ -161,7 +161,7 @@ func DeleteIssueStopwatch(ctx *context.APIContext) { } func prepareIssueStopwatch(ctx *context.APIContext, shouldExist bool) (*issues_model.Issue, error) { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go index a535172462e19..e51baad0b6c5a 100644 --- a/routers/api/v1/repo/issue_subscription.go +++ b/routers/api/v1/repo/issue_subscription.go @@ -104,7 +104,7 @@ func DelIssueSubscription(ctx *context.APIContext) { } func setIssueSubscription(ctx *context.APIContext, watch bool) { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -115,7 +115,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) { return } - user, err := user_model.GetUserByName(ctx, ctx.Params(":user")) + user, err := user_model.GetUserByName(ctx, ctx.PathParam(":user")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.NotFound() @@ -185,7 +185,7 @@ func CheckIssueSubscription(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() @@ -251,7 +251,7 @@ func GetIssueSubscribers(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go index f83855efac111..8d5e9fdad4113 100644 --- a/routers/api/v1/repo/issue_tracked_time.go +++ b/routers/api/v1/repo/issue_tracked_time.go @@ -75,7 +75,7 @@ func ListTrackedTimes(ctx *context.APIContext) { ctx.NotFound("Timetracker is disabled") return } - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound(err) @@ -181,7 +181,7 @@ func AddTime(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.AddTimeOption) - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound(err) @@ -264,7 +264,7 @@ func ResetIssueTime(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound(err) @@ -337,7 +337,7 @@ func DeleteTime(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound(err) @@ -356,7 +356,7 @@ func DeleteTime(ctx *context.APIContext) { return } - time, err := issues_model.GetTrackedTimeByID(ctx, ctx.ParamsInt64(":id")) + time, err := issues_model.GetTrackedTimeByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if db.IsErrNotExist(err) { ctx.NotFound(err) @@ -422,7 +422,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) { ctx.Error(http.StatusBadRequest, "", "time tracking disabled") return } - user, err := user_model.GetUserByName(ctx, ctx.Params(":timetrackingusername")) + user, err := user_model.GetUserByName(ctx, ctx.PathParam(":timetrackingusername")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.NotFound(err) diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index 88444a26250c0..e5115980eb0a9 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -143,7 +143,7 @@ func GetDeployKey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - key, err := asymkey_model.GetDeployKeyByID(ctx, ctx.ParamsInt64(":id")) + key, err := asymkey_model.GetDeployKeyByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if asymkey_model.IsErrDeployKeyNotExist(err) { ctx.NotFound() @@ -279,7 +279,7 @@ func DeleteDeploykey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil { + if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.PathParamInt64(":id")); err != nil { if asymkey_model.IsErrKeyAccessDenied(err) { ctx.Error(http.StatusForbidden, "", "You do not have access to this key") } else { diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go index b6eb51fd20a84..c2c43db6a4a04 100644 --- a/routers/api/v1/repo/label.go +++ b/routers/api/v1/repo/label.go @@ -99,7 +99,7 @@ func GetLabel(ctx *context.APIContext) { l *issues_model.Label err error ) - strID := ctx.Params(":id") + strID := ctx.PathParam(":id") if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil { l, err = issues_model.GetLabelInRepoByName(ctx, ctx.Repo.Repository.ID, strID) } else { @@ -212,7 +212,7 @@ func EditLabel(ctx *context.APIContext) { // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.EditLabelOption) - l, err := issues_model.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + l, err := issues_model.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrRepoLabelNotExist(err) { ctx.NotFound() @@ -276,7 +276,7 @@ func DeleteLabel(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil { + if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")); err != nil { ctx.Error(http.StatusInternalServerError, "DeleteLabel", err) return } diff --git a/routers/api/v1/repo/milestone.go b/routers/api/v1/repo/milestone.go index b9534016e4b87..abe9e4006a8e4 100644 --- a/routers/api/v1/repo/milestone.go +++ b/routers/api/v1/repo/milestone.go @@ -282,7 +282,7 @@ func DeleteMilestone(ctx *context.APIContext) { // getMilestoneByIDOrName get milestone by ID and if not available by name func getMilestoneByIDOrName(ctx *context.APIContext) *issues_model.Milestone { - mile := ctx.Params(":id") + mile := ctx.PathParam(":id") mileID, _ := strconv.ParseInt(mile, 0, 64) if mileID != 0 { diff --git a/routers/api/v1/repo/mirror.go b/routers/api/v1/repo/mirror.go index eddd449206a75..310b82881eac0 100644 --- a/routers/api/v1/repo/mirror.go +++ b/routers/api/v1/repo/mirror.go @@ -224,7 +224,7 @@ func GetPushMirrorByName(ctx *context.APIContext) { return } - mirrorName := ctx.Params(":name") + mirrorName := ctx.PathParam(":name") // Get push mirror of a specific repo by remoteName pushMirror, exist, err := db.Get[repo_model.PushMirror](ctx, repo_model.PushMirrorOptions{ RepoID: ctx.Repo.Repository.ID, @@ -325,7 +325,7 @@ func DeletePushMirrorByRemoteName(ctx *context.APIContext) { return } - remoteName := ctx.Params(":name") + remoteName := ctx.PathParam(":name") // Delete push mirror on repo by name. err := repo_model.DeletePushMirrors(ctx, repo_model.PushMirrorOptions{RepoID: ctx.Repo.Repository.ID, RemoteName: remoteName}) if err != nil { diff --git a/routers/api/v1/repo/notes.go b/routers/api/v1/repo/notes.go index a4a1d4eab7c8d..8689d25e157a2 100644 --- a/routers/api/v1/repo/notes.go +++ b/routers/api/v1/repo/notes.go @@ -52,7 +52,7 @@ func GetNote(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params(":sha") + sha := ctx.PathParam(":sha") if !git.IsValidRefPattern(sha) { ctx.Error(http.StatusUnprocessableEntity, "no valid ref or sha", fmt.Sprintf("no valid ref or sha: %s", sha)) return diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 1fc94708daf1b..ebe876da64609 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -187,7 +187,7 @@ func GetPullRequest(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -244,7 +244,7 @@ func GetPullRequestByBaseHead(ctx *context.APIContext) { var headRepoID int64 var headBranch string - head := ctx.Params("*") + head := ctx.PathParam("*") if strings.Contains(head, ":") { split := strings.SplitN(head, ":", 2) headBranch = split[1] @@ -272,7 +272,7 @@ func GetPullRequestByBaseHead(ctx *context.APIContext) { headBranch = head } - pr, err := issues_model.GetPullRequestByBaseHeadInfo(ctx, ctx.Repo.Repository.ID, headRepoID, ctx.Params(":base"), headBranch) + pr, err := issues_model.GetPullRequestByBaseHeadInfo(ctx, ctx.Repo.Repository.ID, headRepoID, ctx.PathParam(":base"), headBranch) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -332,7 +332,7 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext) { // "$ref": "#/responses/string" // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -342,7 +342,7 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext) { return } var patch bool - if ctx.Params(":diffType") == "diff" { + if ctx.PathParam(":diffType") == "diff" { patch = false } else { patch = true @@ -590,7 +590,7 @@ func EditPullRequest(ctx *context.APIContext) { // "$ref": "#/responses/validationError" form := web.GetForm(ctx).(*api.EditPullRequestOption) - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -804,7 +804,7 @@ func IsPullRequestMerged(ctx *context.APIContext) { // "404": // description: pull request has not been merged - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -862,7 +862,7 @@ func MergePullRequest(ctx *context.APIContext) { form := web.GetForm(ctx).(*forms.MergePullRequestForm) - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -1221,7 +1221,7 @@ func UpdatePullRequest(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -1320,7 +1320,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) { // "423": // "$ref": "#/responses/repoArchivedError" - pullIndex := ctx.ParamsInt64(":index") + pullIndex := ctx.PathParamInt64(":index") pull, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, pullIndex) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { @@ -1406,7 +1406,7 @@ func GetPullRequestCommits(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() @@ -1529,7 +1529,7 @@ func GetPullRequestFiles(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go index 4b481790fb1a8..c2e4966498315 100644 --- a/routers/api/v1/repo/pull_review.go +++ b/routers/api/v1/repo/pull_review.go @@ -61,7 +61,7 @@ func ListPullReviews(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -307,7 +307,7 @@ func CreatePullReview(ctx *context.APIContext) { // "$ref": "#/responses/validationError" opts := web.GetForm(ctx).(*api.CreatePullReviewOptions) - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -534,7 +534,7 @@ func preparePullReviewType(ctx *context.APIContext, pr *issues_model.PullRequest // prepareSingleReview return review, related pull and false or nil, nil and true if an error happen func prepareSingleReview(ctx *context.APIContext) (*issues_model.Review, *issues_model.PullRequest, bool) { - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -544,7 +544,7 @@ func prepareSingleReview(ctx *context.APIContext) (*issues_model.Review, *issues return nil, nil, true } - review, err := issues_model.GetReviewByID(ctx, ctx.ParamsInt64(":id")) + review, err := issues_model.GetReviewByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrReviewNotExist(err) { ctx.NotFound("GetReviewByID", err) @@ -658,7 +658,7 @@ func DeleteReviewRequests(ctx *context.APIContext) { } func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions, isAdd bool) { - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index f92fb86f5cb0b..ef587f6274b91 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -50,7 +50,7 @@ func GetRelease(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") release, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id) if err != nil && !repo_model.IsErrReleaseNotExist(err) { ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err) @@ -317,7 +317,7 @@ func EditRelease(ctx *context.APIContext) { // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.EditReleaseOption) - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id) if err != nil && !repo_model.IsErrReleaseNotExist(err) { ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err) @@ -394,7 +394,7 @@ func DeleteRelease(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, id) if err != nil && !repo_model.IsErrReleaseNotExist(err) { ctx.Error(http.StatusInternalServerError, "GetReleaseForRepoByID", err) diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go index 59fd83e3a2793..4a2371e012aa9 100644 --- a/routers/api/v1/repo/release_attachment.go +++ b/routers/api/v1/repo/release_attachment.go @@ -72,12 +72,12 @@ func GetReleaseAttachment(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - releaseID := ctx.ParamsInt64(":id") + releaseID := ctx.PathParamInt64(":id") if !checkReleaseMatchRepo(ctx, releaseID) { return } - attachID := ctx.ParamsInt64(":attachment_id") + attachID := ctx.PathParamInt64(":attachment_id") attach, err := repo_model.GetAttachmentByID(ctx, attachID) if err != nil { if repo_model.IsErrAttachmentNotExist(err) { @@ -126,7 +126,7 @@ func ListReleaseAttachments(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - releaseID := ctx.ParamsInt64(":id") + releaseID := ctx.PathParamInt64(":id") release, err := repo_model.GetReleaseByID(ctx, releaseID) if err != nil { if repo_model.IsErrReleaseNotExist(err) { @@ -199,7 +199,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) { } // Check if release exists an load release - releaseID := ctx.ParamsInt64(":id") + releaseID := ctx.PathParamInt64(":id") if !checkReleaseMatchRepo(ctx, releaseID) { return } @@ -297,12 +297,12 @@ func EditReleaseAttachment(ctx *context.APIContext) { form := web.GetForm(ctx).(*api.EditAttachmentOptions) // Check if release exists an load release - releaseID := ctx.ParamsInt64(":id") + releaseID := ctx.PathParamInt64(":id") if !checkReleaseMatchRepo(ctx, releaseID) { return } - attachID := ctx.ParamsInt64(":attachment_id") + attachID := ctx.PathParamInt64(":attachment_id") attach, err := repo_model.GetAttachmentByID(ctx, attachID) if err != nil { if repo_model.IsErrAttachmentNotExist(err) { @@ -365,12 +365,12 @@ func DeleteReleaseAttachment(ctx *context.APIContext) { // "$ref": "#/responses/notFound" // Check if release exists an load release - releaseID := ctx.ParamsInt64(":id") + releaseID := ctx.PathParamInt64(":id") if !checkReleaseMatchRepo(ctx, releaseID) { return } - attachID := ctx.ParamsInt64(":attachment_id") + attachID := ctx.PathParamInt64(":attachment_id") attach, err := repo_model.GetAttachmentByID(ctx, attachID) if err != nil { if repo_model.IsErrAttachmentNotExist(err) { diff --git a/routers/api/v1/repo/release_tags.go b/routers/api/v1/repo/release_tags.go index f845fad53bdd1..6df47af8d98e5 100644 --- a/routers/api/v1/repo/release_tags.go +++ b/routers/api/v1/repo/release_tags.go @@ -42,7 +42,7 @@ func GetReleaseByTag(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - tag := ctx.Params(":tag") + tag := ctx.PathParam(":tag") release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag) if err != nil { @@ -95,7 +95,7 @@ func DeleteReleaseByTag(ctx *context.APIContext) { // "422": // "$ref": "#/responses/validationError" - tag := ctx.Params(":tag") + tag := ctx.PathParam(":tag") release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag) if err != nil { diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 4f617d27afa4a..1bcec8fcf7e72 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -491,7 +491,7 @@ func CreateOrgRepo(ctx *context.APIContext) { // "403": // "$ref": "#/responses/forbidden" opt := web.GetForm(ctx).(*api.CreateRepoOption) - org, err := organization.GetOrgByName(ctx, ctx.Params(":org")) + org, err := organization.GetOrgByName(ctx, ctx.PathParam(":org")) if err != nil { if organization.IsErrOrgNotExist(err) { ctx.Error(http.StatusUnprocessableEntity, "", err) @@ -571,7 +571,7 @@ func GetByID(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - repo, err := repo_model.GetRepositoryByID(ctx, ctx.ParamsInt64(":id")) + repo, err := repo_model.GetRepositoryByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if repo_model.IsErrRepoNotExist(err) { ctx.NotFound() diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 9e36ea0aed3bf..8c910a68f9098 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -53,7 +53,7 @@ func NewCommitStatus(ctx *context.APIContext) { // "$ref": "#/responses/notFound" form := web.GetForm(ctx).(*api.CreateStatusOption) - sha := ctx.Params("sha") + sha := ctx.PathParam("sha") if len(sha) == 0 { ctx.Error(http.StatusBadRequest, "sha not given", nil) return @@ -123,7 +123,7 @@ func GetCommitStatuses(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - getCommitStatuses(ctx, ctx.Params("sha")) + getCommitStatuses(ctx, ctx.PathParam("sha")) } // GetCommitStatusesByRef returns all statuses for any given commit ref @@ -177,7 +177,7 @@ func GetCommitStatusesByRef(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - filter := utils.ResolveRefOrSha(ctx, ctx.Params("ref")) + filter := utils.ResolveRefOrSha(ctx, ctx.PathParam("ref")) if ctx.Written() { return } @@ -257,7 +257,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := utils.ResolveRefOrSha(ctx, ctx.Params("ref")) + sha := utils.ResolveRefOrSha(ctx, ctx.PathParam("ref")) if ctx.Written() { return } diff --git a/routers/api/v1/repo/tag.go b/routers/api/v1/repo/tag.go index f72034950f2a7..a72df78666e40 100644 --- a/routers/api/v1/repo/tag.go +++ b/routers/api/v1/repo/tag.go @@ -102,7 +102,7 @@ func GetAnnotatedTag(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params("sha") + sha := ctx.PathParam("sha") if len(sha) == 0 { ctx.Error(http.StatusBadRequest, "", "SHA not provided") return @@ -147,7 +147,7 @@ func GetTag(ctx *context.APIContext) { // "$ref": "#/responses/Tag" // "404": // "$ref": "#/responses/notFound" - tagName := ctx.Params("*") + tagName := ctx.PathParam("*") tag, err := ctx.Repo.GitRepo.GetTag(tagName) if err != nil { @@ -263,7 +263,7 @@ func DeleteTag(ctx *context.APIContext) { // "$ref": "#/responses/validationError" // "423": // "$ref": "#/responses/repoArchivedError" - tagName := ctx.Params("*") + tagName := ctx.PathParam("*") tag, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName) if err != nil { @@ -358,7 +358,7 @@ func GetTagProtection(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repo := ctx.Repo.Repository - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") pt, err := git_model.GetProtectedTagByID(ctx, id) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err) @@ -522,7 +522,7 @@ func EditTagProtection(ctx *context.APIContext) { repo := ctx.Repo.Repository form := web.GetForm(ctx).(*api.EditTagProtectionOption) - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") pt, err := git_model.GetProtectedTagByID(ctx, id) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err) @@ -617,7 +617,7 @@ func DeleteTagProtection(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repo := ctx.Repo.Repository - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") pt, err := git_model.GetProtectedTagByID(ctx, id) if err != nil { ctx.Error(http.StatusInternalServerError, "GetProtectedTagByID", err) diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go index 0ecf3a39d8fd6..ddd325482da35 100644 --- a/routers/api/v1/repo/teams.go +++ b/routers/api/v1/repo/teams.go @@ -222,7 +222,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) { } func getTeamByParam(ctx *context.APIContext) *organization.Team { - team, err := organization.GetTeam(ctx, ctx.Repo.Owner.ID, ctx.Params(":team")) + team, err := organization.GetTeam(ctx, ctx.Repo.Owner.ID, ctx.PathParam(":team")) if err != nil { if organization.IsErrTeamNotExist(err) { ctx.Error(http.StatusNotFound, "TeamNotExit", err) diff --git a/routers/api/v1/repo/topic.go b/routers/api/v1/repo/topic.go index 9852caa9896de..6b9eedf6e0ea5 100644 --- a/routers/api/v1/repo/topic.go +++ b/routers/api/v1/repo/topic.go @@ -162,7 +162,7 @@ func AddTopic(ctx *context.APIContext) { // "422": // "$ref": "#/responses/invalidTopicsError" - topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic"))) + topicName := strings.TrimSpace(strings.ToLower(ctx.PathParam(":topic"))) if !repo_model.ValidateTopic(topicName) { ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ @@ -229,7 +229,7 @@ func DeleteTopic(ctx *context.APIContext) { // "422": // "$ref": "#/responses/invalidTopicsError" - topicName := strings.TrimSpace(strings.ToLower(ctx.Params(":topic"))) + topicName := strings.TrimSpace(strings.ToLower(ctx.PathParam(":topic"))) if !repo_model.ValidateTopic(topicName) { ctx.JSON(http.StatusUnprocessableEntity, map[string]any{ diff --git a/routers/api/v1/repo/tree.go b/routers/api/v1/repo/tree.go index 353a996d5b0d1..efb247c19e2fe 100644 --- a/routers/api/v1/repo/tree.go +++ b/routers/api/v1/repo/tree.go @@ -56,7 +56,7 @@ func GetTree(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - sha := ctx.Params(":sha") + sha := ctx.PathParam(":sha") if len(sha) == 0 { ctx.Error(http.StatusBadRequest, "", "sha not provided") return diff --git a/routers/api/v1/shared/block.go b/routers/api/v1/shared/block.go index a1e65625ed35e..490a48f81c858 100644 --- a/routers/api/v1/shared/block.go +++ b/routers/api/v1/shared/block.go @@ -40,7 +40,7 @@ func ListBlocks(ctx *context.APIContext, blocker *user_model.User) { } func CheckUserBlock(ctx *context.APIContext, blocker *user_model.User) { - blockee, err := user_model.GetUserByName(ctx, ctx.Params("username")) + blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username")) if err != nil { ctx.NotFound("GetUserByName", err) return @@ -60,7 +60,7 @@ func CheckUserBlock(ctx *context.APIContext, blocker *user_model.User) { } func BlockUser(ctx *context.APIContext, blocker *user_model.User) { - blockee, err := user_model.GetUserByName(ctx, ctx.Params("username")) + blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username")) if err != nil { ctx.NotFound("GetUserByName", err) return @@ -79,7 +79,7 @@ func BlockUser(ctx *context.APIContext, blocker *user_model.User) { } func UnblockUser(ctx *context.APIContext, doer, blocker *user_model.User) { - blockee, err := user_model.GetUserByName(ctx, ctx.Params("username")) + blockee, err := user_model.GetUserByName(ctx, ctx.PathParam("username")) if err != nil { ctx.NotFound("GetUserByName", err) return diff --git a/routers/api/v1/user/action.go b/routers/api/v1/user/action.go index bf78c2c86493a..22707196f4cca 100644 --- a/routers/api/v1/user/action.go +++ b/routers/api/v1/user/action.go @@ -49,7 +49,7 @@ func CreateOrUpdateSecret(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption) - _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Doer.ID, 0, ctx.Params("secretname"), opt.Data) + _, created, err := secret_service.CreateOrUpdateSecret(ctx, ctx.Doer.ID, 0, ctx.PathParam("secretname"), opt.Data) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "CreateOrUpdateSecret", err) @@ -91,7 +91,7 @@ func DeleteSecret(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - err := secret_service.DeleteSecretByName(ctx, ctx.Doer.ID, 0, ctx.Params("secretname")) + err := secret_service.DeleteSecretByName(ctx, ctx.Doer.ID, 0, ctx.PathParam("secretname")) if err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteSecret", err) @@ -138,7 +138,7 @@ func CreateVariable(ctx *context.APIContext) { opt := web.GetForm(ctx).(*api.CreateVariableOption) ownerID := ctx.Doer.ID - variableName := ctx.Params("variablename") + variableName := ctx.PathParam("variablename") v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ownerID, @@ -198,7 +198,7 @@ func UpdateVariable(ctx *context.APIContext) { v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ctx.Doer.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -210,7 +210,7 @@ func UpdateVariable(ctx *context.APIContext) { } if opt.Name == "" { - opt.Name = ctx.Params("variablename") + opt.Name = ctx.PathParam("variablename") } if _, err := actions_service.UpdateVariable(ctx, v.ID, opt.Name, opt.Value); err != nil { if errors.Is(err, util.ErrInvalidArgument) { @@ -247,7 +247,7 @@ func DeleteVariable(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - if err := actions_service.DeleteVariableByName(ctx, ctx.Doer.ID, 0, ctx.Params("variablename")); err != nil { + if err := actions_service.DeleteVariableByName(ctx, ctx.Doer.ID, 0, ctx.PathParam("variablename")); err != nil { if errors.Is(err, util.ErrInvalidArgument) { ctx.Error(http.StatusBadRequest, "DeleteVariableByName", err) } else if errors.Is(err, util.ErrNotExist) { @@ -284,7 +284,7 @@ func GetVariable(ctx *context.APIContext) { v, err := actions_service.GetVariable(ctx, actions_model.FindVariablesOpts{ OwnerID: ctx.Doer.ID, - Name: ctx.Params("variablename"), + Name: ctx.PathParam("variablename"), }) if err != nil { if errors.Is(err, util.ErrNotExist) { diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index 88e314ed31ba7..60354b1f26ec7 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -160,7 +160,7 @@ func DeleteAccessToken(ctx *context.APIContext) { // "422": // "$ref": "#/responses/error" - token := ctx.Params(":id") + token := ctx.PathParam(":id") tokenID, _ := strconv.ParseInt(token, 0, 64) if tokenID == 0 { @@ -300,7 +300,7 @@ func DeleteOauth2Application(ctx *context.APIContext) { // "$ref": "#/responses/empty" // "404": // "$ref": "#/responses/notFound" - appID := ctx.ParamsInt64(":id") + appID := ctx.PathParamInt64(":id") if err := auth_model.DeleteOAuth2Application(ctx, appID, ctx.Doer.ID); err != nil { if auth_model.IsErrOAuthApplicationNotFound(err) { ctx.NotFound() @@ -332,7 +332,7 @@ func GetOauth2Application(ctx *context.APIContext) { // "$ref": "#/responses/OAuth2Application" // "404": // "$ref": "#/responses/notFound" - appID := ctx.ParamsInt64(":id") + appID := ctx.PathParamInt64(":id") app, err := auth_model.GetOAuth2ApplicationByID(ctx, appID) if err != nil { if auth_model.IsErrOauthClientIDInvalid(err) || auth_model.IsErrOAuthApplicationNotFound(err) { @@ -376,7 +376,7 @@ func UpdateOauth2Application(ctx *context.APIContext) { // "$ref": "#/responses/OAuth2Application" // "404": // "$ref": "#/responses/notFound" - appID := ctx.ParamsInt64(":id") + appID := ctx.PathParamInt64(":id") data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions) diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go index 5a2f995e1b5ad..ba5c0fdc45411 100644 --- a/routers/api/v1/user/gpg_key.go +++ b/routers/api/v1/user/gpg_key.go @@ -116,7 +116,7 @@ func GetGPGKey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - key, err := asymkey_model.GetGPGKeyForUserByID(ctx, ctx.Doer.ID, ctx.ParamsInt64(":id")) + key, err := asymkey_model.GetGPGKeyForUserByID(ctx, ctx.Doer.ID, ctx.PathParamInt64(":id")) if err != nil { if asymkey_model.IsErrGPGKeyNotExist(err) { ctx.NotFound() @@ -280,7 +280,7 @@ func DeleteGPGKey(ctx *context.APIContext) { return } - if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil { + if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.PathParamInt64(":id")); err != nil { if asymkey_model.IsErrGPGKeyAccessDenied(err) { ctx.Error(http.StatusForbidden, "", "You do not have access to this key") } else { diff --git a/routers/api/v1/user/helper.go b/routers/api/v1/user/helper.go index 8b5c64e291988..23a526cd676a5 100644 --- a/routers/api/v1/user/helper.go +++ b/routers/api/v1/user/helper.go @@ -12,7 +12,7 @@ import ( // GetUserByParamsName get user by name func GetUserByParamsName(ctx *context.APIContext, name string) *user_model.User { - username := ctx.Params(name) + username := ctx.PathParam(name) user, err := user_model.GetUserByName(ctx, username) if err != nil { if user_model.IsErrUserNotExist(err) { diff --git a/routers/api/v1/user/hook.go b/routers/api/v1/user/hook.go index 9d9ca5bf01059..b4605c8a29208 100644 --- a/routers/api/v1/user/hook.go +++ b/routers/api/v1/user/hook.go @@ -57,7 +57,7 @@ func GetHook(ctx *context.APIContext) { // "200": // "$ref": "#/responses/Hook" - hook, err := utils.GetOwnerHook(ctx, ctx.Doer.ID, ctx.ParamsInt64("id")) + hook, err := utils.GetOwnerHook(ctx, ctx.Doer.ID, ctx.PathParamInt64("id")) if err != nil { return } @@ -129,7 +129,7 @@ func EditHook(ctx *context.APIContext) { ctx, ctx.Doer, web.GetForm(ctx).(*api.EditHookOption), - ctx.ParamsInt64("id"), + ctx.PathParamInt64("id"), ) } @@ -154,6 +154,6 @@ func DeleteHook(ctx *context.APIContext) { utils.DeleteOwnerHook( ctx, ctx.Doer, - ctx.ParamsInt64("id"), + ctx.PathParamInt64("id"), ) } diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index d9456e7ec6087..e4278c2ec0ef6 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -55,7 +55,7 @@ func listPublicKeys(ctx *context.APIContext, user *user_model.User) { var count int fingerprint := ctx.FormString("fingerprint") - username := ctx.Params("username") + username := ctx.PathParam("username") if fingerprint != "" { var userID int64 // Unrestricted @@ -179,7 +179,7 @@ func GetPublicKey(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.ParamsInt64(":id")) + key, err := asymkey_model.GetPublicKeyByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if asymkey_model.IsErrKeyNotExist(err) { ctx.NotFound() @@ -274,7 +274,7 @@ func DeletePublicKey(ctx *context.APIContext) { return } - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(ctx, id) if err != nil { if asymkey_model.IsErrKeyNotExist(err) { diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 09147cd2ae00b..fedad87fc4fa5 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -113,7 +113,7 @@ func GetInfo(ctx *context.APIContext) { if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) { // fake ErrUserNotExist error message to not leak information about existence - ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.Params(":username")}) + ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.PathParam(":username")}) return } ctx.JSON(http.StatusOK, convert.ToUser(ctx, ctx.ContextUser, ctx.Doer)) diff --git a/routers/common/middleware.go b/routers/common/middleware.go index de49648396fd2..51e42d87a0b9e 100644 --- a/routers/common/middleware.go +++ b/routers/common/middleware.go @@ -19,13 +19,23 @@ import ( "gitea.com/go-chi/session" "github.com/chi-middleware/proxy" - chi "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5" ) // ProtocolMiddlewares returns HTTP protocol related middlewares, and it provides a global panic recovery func ProtocolMiddlewares() (handlers []any) { - // first, normalize the URL path - handlers = append(handlers, normalizeRequestPathMiddleware) + // make sure chi uses EscapedPath(RawPath) as RoutePath, then "%2f" could be handled correctly + handlers = append(handlers, func(next http.Handler) http.Handler { + return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { + ctx := chi.RouteContext(req.Context()) + if req.URL.RawPath == "" { + ctx.RoutePath = req.URL.EscapedPath() + } else { + ctx.RoutePath = req.URL.RawPath + } + next.ServeHTTP(resp, req) + }) + }) // prepare the ContextData and panic recovery handlers = append(handlers, func(next http.Handler) http.Handler { @@ -75,58 +85,6 @@ func ProtocolMiddlewares() (handlers []any) { return handlers } -func normalizeRequestPathMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { - // escape the URL RawPath to ensure that all routing is done using a correctly escaped URL - req.URL.RawPath = req.URL.EscapedPath() - - urlPath := req.URL.RawPath - rctx := chi.RouteContext(req.Context()) - if rctx != nil && rctx.RoutePath != "" { - urlPath = rctx.RoutePath - } - - normalizedPath := strings.TrimRight(urlPath, "/") - // the following code block is a slow-path for replacing all repeated slashes "//" to one single "/" - // if the path doesn't have repeated slashes, then no need to execute it - if strings.Contains(normalizedPath, "//") { - buf := &strings.Builder{} - prevWasSlash := false - for _, chr := range normalizedPath { - if chr != '/' || !prevWasSlash { - buf.WriteRune(chr) - } - prevWasSlash = chr == '/' - } - normalizedPath = buf.String() - } - - if setting.UseSubURLPath { - remainingPath, ok := strings.CutPrefix(normalizedPath, setting.AppSubURL+"/") - if ok { - normalizedPath = "/" + remainingPath - } else if normalizedPath == setting.AppSubURL { - normalizedPath = "/" - } else if !strings.HasPrefix(normalizedPath+"/", "/v2/") { - // do not respond to other requests, to simulate a real sub-path environment - http.Error(resp, "404 page not found, sub-path is: "+setting.AppSubURL, http.StatusNotFound) - return - } - // TODO: it's not quite clear about how req.URL and rctx.RoutePath work together. - // Fortunately, it is only used for debug purpose, we have enough time to figure it out in the future. - req.URL.RawPath = normalizedPath - req.URL.Path = normalizedPath - } - - if rctx == nil { - req.URL.Path = normalizedPath - } else { - rctx.RoutePath = normalizedPath - } - next.ServeHTTP(resp, req) - }) -} - func Sessioner() func(next http.Handler) http.Handler { return session.Sessioner(session.Options{ Provider: setting.SessionConfig.Provider, diff --git a/routers/common/middleware_test.go b/routers/common/middleware_test.go deleted file mode 100644 index c96071c3a8a2d..0000000000000 --- a/routers/common/middleware_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2022 The Gitea Authors. All rights reserved. -// SPDX-License-Identifier: MIT -package common - -import ( - "net/http" - "net/http/httptest" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestStripSlashesMiddleware(t *testing.T) { - type test struct { - name string - expectedPath string - inputPath string - } - - tests := []test{ - { - name: "path with multiple slashes", - inputPath: "https://github.com///go-gitea//gitea.git", - expectedPath: "/go-gitea/gitea.git", - }, - { - name: "path with no slashes", - inputPath: "https://github.com/go-gitea/gitea.git", - expectedPath: "/go-gitea/gitea.git", - }, - { - name: "path with slashes in the middle", - inputPath: "https://git.data.coop//halfd/new-website.git", - expectedPath: "/halfd/new-website.git", - }, - { - name: "path with slashes in the middle", - inputPath: "https://git.data.coop//halfd/new-website.git", - expectedPath: "/halfd/new-website.git", - }, - { - name: "path with slashes in the end", - inputPath: "/user2//repo1/", - expectedPath: "/user2/repo1", - }, - { - name: "path with slashes and query params", - inputPath: "/repo//migrate?service_type=3", - expectedPath: "/repo/migrate", - }, - { - name: "path with encoded slash", - inputPath: "/user2/%2F%2Frepo1", - expectedPath: "/user2/%2F%2Frepo1", - }, - } - - for _, tt := range tests { - testMiddleware := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - assert.Equal(t, tt.expectedPath, r.URL.Path) - }) - - // pass the test middleware to validate the changes - handlerToTest := normalizeRequestPathMiddleware(testMiddleware) - // create a mock request to use - req := httptest.NewRequest("GET", tt.inputPath, nil) - // call the handler using a mock response recorder - handlerToTest.ServeHTTP(httptest.NewRecorder(), req) - } -} diff --git a/routers/init.go b/routers/init.go index 56c95cd1cab7c..e21f763c1e527 100644 --- a/routers/init.go +++ b/routers/init.go @@ -177,9 +177,9 @@ func InitWebInstalled(ctx context.Context) { } // NormalRoutes represents non install routes -func NormalRoutes() *web.Route { +func NormalRoutes() *web.Router { _ = templates.HTMLRenderer() - r := web.NewRoute() + r := web.NewRouter() r.Use(common.ProtocolMiddlewares()...) r.Mount("/", web_routers.Routes()) @@ -191,7 +191,8 @@ func NormalRoutes() *web.Route { if setting.Packages.Enabled { // This implements package support for most package managers r.Mount("/api/packages", packages_router.CommonRoutes()) - // This implements the OCI API (Note this is not preceded by /api but is instead /v2) + // This implements the OCI API, this container registry "/v2" endpoint must be in the root of the site. + // If site admin deploys Gitea in a sub-path, they must configure their reverse proxy to map the "https://host/v2" endpoint to Gitea. r.Mount("/v2", packages_router.ContainerRoutes()) } diff --git a/routers/install/routes.go b/routers/install/routes.go index 06c9d389a60f4..7309a405d415d 100644 --- a/routers/install/routes.go +++ b/routers/install/routes.go @@ -17,12 +17,12 @@ import ( ) // Routes registers the installation routes -func Routes() *web.Route { - base := web.NewRoute() +func Routes() *web.Router { + base := web.NewRouter() base.Use(common.ProtocolMiddlewares()...) base.Methods("GET, HEAD", "/assets/*", public.FileHandlerFunc()) - r := web.NewRoute() + r := web.NewRouter() r.Use(common.Sessioner(), Contexter()) r.Get("/", Install) // it must be on the root, because the "install.js" use the window.location to replace the "localhost" AppURL r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall) diff --git a/routers/private/default_branch.go b/routers/private/default_branch.go index 33890be6a9277..7be909f955d17 100644 --- a/routers/private/default_branch.go +++ b/routers/private/default_branch.go @@ -16,9 +16,9 @@ import ( // SetDefaultBranch updates the default branch func SetDefaultBranch(ctx *gitea_context.PrivateContext) { - ownerName := ctx.Params(":owner") - repoName := ctx.Params(":repo") - branch := ctx.Params(":branch") + ownerName := ctx.PathParam(":owner") + repoName := ctx.PathParam(":repo") + branch := ctx.PathParam(":branch") ctx.Repo.Repository.DefaultBranch = branch if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil { diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go index 0c2c1836ed104..2d1688523c488 100644 --- a/routers/private/hook_post_receive.go +++ b/routers/private/hook_post_receive.go @@ -40,8 +40,8 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) { // b) our update function will likely change the repository in the db so we will need to refresh it // c) we don't always need the repo - ownerName := ctx.Params(":owner") - repoName := ctx.Params(":repo") + ownerName := ctx.PathParam(":owner") + repoName := ctx.PathParam(":repo") // defer getting the repository at this point - as we should only retrieve it if we're going to call update var ( diff --git a/routers/private/internal.go b/routers/private/internal.go index ede310113ca45..61e604b7a932e 100644 --- a/routers/private/internal.go +++ b/routers/private/internal.go @@ -48,8 +48,8 @@ func bind[T any](_ T) any { // Routes registers all internal APIs routes to web application. // These APIs will be invoked by internal commands for example `gitea serv` and etc. -func Routes() *web.Route { - r := web.NewRoute() +func Routes() *web.Router { + r := web.NewRouter() r.Use(context.PrivateContexter()) r.Use(CheckInternalToken) // Log the real ip address of the request from SSH is really helpful for diagnosing sometimes. diff --git a/routers/private/internal_repo.go b/routers/private/internal_repo.go index e8ee8ba8ac3fc..aad0a3fb1aa83 100644 --- a/routers/private/internal_repo.go +++ b/routers/private/internal_repo.go @@ -19,8 +19,8 @@ import ( // RepoAssignment assigns the repository and gitrepository to the private context func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc { - ownerName := ctx.Params(":owner") - repoName := ctx.Params(":repo") + ownerName := ctx.PathParam(":owner") + repoName := ctx.PathParam(":repo") repo := loadRepository(ctx, ownerName, repoName) if ctx.Written() { diff --git a/routers/private/key.go b/routers/private/key.go index 5b8f238a83ebc..063db76520fca 100644 --- a/routers/private/key.go +++ b/routers/private/key.go @@ -14,8 +14,8 @@ import ( // UpdatePublicKeyInRepo update public key and deploy key updates func UpdatePublicKeyInRepo(ctx *context.PrivateContext) { - keyID := ctx.ParamsInt64(":id") - repoID := ctx.ParamsInt64(":repoid") + keyID := ctx.PathParamInt64(":id") + repoID := ctx.PathParamInt64(":repoid") if err := asymkey_model.UpdatePublicKeyUpdated(ctx, keyID); err != nil { ctx.JSON(http.StatusInternalServerError, private.Response{ Err: err.Error(), diff --git a/routers/private/manager.go b/routers/private/manager.go index a6aa03e4ec954..c712bbcf21f7b 100644 --- a/routers/private/manager.go +++ b/routers/private/manager.go @@ -88,8 +88,8 @@ func SetLogSQL(ctx *context.PrivateContext) { // RemoveLogger removes a logger func RemoveLogger(ctx *context.PrivateContext) { - logger := ctx.Params("logger") - writer := ctx.Params("writer") + logger := ctx.PathParam("logger") + writer := ctx.PathParam("writer") err := log.GetManager().GetLogger(logger).RemoveWriter(writer) if err != nil { ctx.JSON(http.StatusInternalServerError, private.Response{ diff --git a/routers/private/serv.go b/routers/private/serv.go index 1c309865d7df0..dbb28cc2bb072 100644 --- a/routers/private/serv.go +++ b/routers/private/serv.go @@ -25,7 +25,7 @@ import ( // ServNoCommand returns information about the provided keyid func ServNoCommand(ctx *context.PrivateContext) { - keyID := ctx.ParamsInt64(":keyid") + keyID := ctx.PathParamInt64(":keyid") if keyID <= 0 { ctx.JSON(http.StatusBadRequest, private.Response{ UserMsg: fmt.Sprintf("Bad key id: %d", keyID), @@ -77,9 +77,9 @@ func ServNoCommand(ctx *context.PrivateContext) { // ServCommand returns information about the provided keyid func ServCommand(ctx *context.PrivateContext) { - keyID := ctx.ParamsInt64(":keyid") - ownerName := ctx.Params(":owner") - repoName := ctx.Params(":repo") + keyID := ctx.PathParamInt64(":keyid") + ownerName := ctx.PathParam(":owner") + repoName := ctx.PathParam(":repo") mode := perm.AccessMode(ctx.FormInt("mode")) // Set the basic parts of the results to return diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go index ba487d10457d8..3b89be0f8fc26 100644 --- a/routers/web/admin/auths.go +++ b/routers/web/admin/auths.go @@ -337,7 +337,7 @@ func EditAuthSource(ctx *context.Context) { oauth2providers := oauth2.GetSupportedOAuth2Providers() ctx.Data["OAuth2Providers"] = oauth2providers - source, err := auth.GetSourceByID(ctx, ctx.ParamsInt64(":authid")) + source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid")) if err != nil { ctx.ServerError("auth.GetSourceByID", err) return @@ -371,7 +371,7 @@ func EditAuthSourcePost(ctx *context.Context) { oauth2providers := oauth2.GetSupportedOAuth2Providers() ctx.Data["OAuth2Providers"] = oauth2providers - source, err := auth.GetSourceByID(ctx, ctx.ParamsInt64(":authid")) + source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid")) if err != nil { ctx.ServerError("auth.GetSourceByID", err) return @@ -442,7 +442,7 @@ func EditAuthSourcePost(ctx *context.Context) { // DeleteAuthSource response for deleting an auth source func DeleteAuthSource(ctx *context.Context) { - source, err := auth.GetSourceByID(ctx, ctx.ParamsInt64(":authid")) + source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64(":authid")) if err != nil { ctx.ServerError("auth.GetSourceByID", err) return @@ -454,7 +454,7 @@ func DeleteAuthSource(ctx *context.Context) { } else { ctx.Flash.Error(fmt.Sprintf("auth_service.DeleteSource: %v", err)) } - ctx.JSONRedirect(setting.AppSubURL + "/admin/auths/" + url.PathEscape(ctx.Params(":authid"))) + ctx.JSONRedirect(setting.AppSubURL + "/admin/auths/" + url.PathEscape(ctx.PathParam(":authid"))) return } log.Trace("Authentication deleted by admin(%s): %d", ctx.Doer.Name, source.ID) diff --git a/routers/web/admin/queue.go b/routers/web/admin/queue.go index d8c50730b144e..dce8f8077f598 100644 --- a/routers/web/admin/queue.go +++ b/routers/web/admin/queue.go @@ -24,7 +24,7 @@ func Queues(ctx *context.Context) { // QueueManage shows details for a specific queue func QueueManage(ctx *context.Context) { - qid := ctx.ParamsInt64("qid") + qid := ctx.PathParamInt64("qid") mq := queue.GetManager().GetManagedQueue(qid) if mq == nil { ctx.Status(http.StatusNotFound) @@ -38,7 +38,7 @@ func QueueManage(ctx *context.Context) { // QueueSet sets the maximum number of workers and other settings for this queue func QueueSet(ctx *context.Context) { - qid := ctx.ParamsInt64("qid") + qid := ctx.PathParamInt64("qid") mq := queue.GetManager().GetManagedQueue(qid) if mq == nil { ctx.Status(http.StatusNotFound) @@ -72,7 +72,7 @@ func QueueRemoveAllItems(ctx *context.Context) { // Gitea's queue doesn't have transaction support // So in rare cases, the queue could be corrupted/out-of-sync // Site admin could remove all items from the queue to make it work again - qid := ctx.ParamsInt64("qid") + qid := ctx.PathParamInt64("qid") mq := queue.GetManager().GetManagedQueue(qid) if mq == nil { ctx.Status(http.StatusNotFound) diff --git a/routers/web/admin/stacktrace.go b/routers/web/admin/stacktrace.go index d6def94bb492a..b3b635af5b6de 100644 --- a/routers/web/admin/stacktrace.go +++ b/routers/web/admin/stacktrace.go @@ -40,7 +40,7 @@ func Stacktrace(ctx *context.Context) { // StacktraceCancel cancels a process func StacktraceCancel(ctx *context.Context) { - pid := ctx.Params("pid") + pid := ctx.PathParam("pid") process.GetManager().Cancel(process.IDType(pid)) ctx.JSONRedirect(setting.AppSubURL + "/admin/monitor/stacktrace") } diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index d2330d5fa1884..623b39b4efcfa 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -219,7 +219,7 @@ func NewUserPost(ctx *context.Context) { } func prepareUserInfo(ctx *context.Context) *user_model.User { - u, err := user_model.GetUserByID(ctx, ctx.ParamsInt64(":userid")) + u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64(":userid")) if err != nil { if user_model.IsErrUserNotExist(err) { ctx.Redirect(setting.AppSubURL + "/admin/users") @@ -481,12 +481,12 @@ func EditUserPost(ctx *context.Context) { } ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) } // DeleteUser response for deleting a user func DeleteUser(ctx *context.Context) { - u, err := user_model.GetUserByID(ctx, ctx.ParamsInt64(":userid")) + u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64(":userid")) if err != nil { ctx.ServerError("GetUserByID", err) return @@ -495,7 +495,7 @@ func DeleteUser(ctx *context.Context) { // admin should not delete themself if u.ID == ctx.Doer.ID { ctx.Flash.Error(ctx.Tr("admin.users.cannot_delete_self")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) return } @@ -503,16 +503,16 @@ func DeleteUser(ctx *context.Context) { switch { case models.IsErrUserOwnRepos(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) case models.IsErrUserHasOrgs(err): ctx.Flash.Error(ctx.Tr("admin.users.still_has_org")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) case models.IsErrUserOwnPackages(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_packages")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) case models.IsErrDeleteLastAdminUser(err): ctx.Flash.Error(ctx.Tr("auth.last_admin")) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.PathParam(":userid"))) default: ctx.ServerError("DeleteUser", err) } diff --git a/routers/web/auth/auth_test.go b/routers/web/auth/auth_test.go index 45525a5c6fa31..cbcb2a52222e2 100644 --- a/routers/web/auth/auth_test.go +++ b/routers/web/auth/auth_test.go @@ -71,7 +71,7 @@ func TestSignUpOAuth2ButMissingFields(t *testing.T) { mockOpt := contexttest.MockContextOption{SessionStore: session.NewMockStore("dummy-sid")} ctx, resp := contexttest.MockContext(t, "/user/oauth2/dummy-auth-source/callback?code=dummy-code", mockOpt) - ctx.SetParams("provider", "dummy-auth-source") + ctx.SetPathParam("provider", "dummy-auth-source") SignInOAuthCallback(ctx) assert.Equal(t, http.StatusSeeOther, resp.Code) assert.Equal(t, "/user/link_account", test.RedirectURL(resp)) diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index b337b6b156959..50f0dff2b62df 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -865,7 +865,7 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect // SignInOAuth handles the OAuth2 login buttons func SignInOAuth(ctx *context.Context) { - provider := ctx.Params(":provider") + provider := ctx.PathParam(":provider") authSource, err := auth.GetActiveOAuth2SourceByName(ctx, provider) if err != nil { @@ -904,7 +904,7 @@ func SignInOAuth(ctx *context.Context) { // SignInOAuthCallback handles the callback from the given provider func SignInOAuthCallback(ctx *context.Context) { - provider := ctx.Params(":provider") + provider := ctx.PathParam(":provider") if ctx.Req.FormValue("error") != "" { var errorKeyValues []string diff --git a/routers/web/devtest/devtest.go b/routers/web/devtest/devtest.go index dd20663f94bd7..8c343197d91b9 100644 --- a/routers/web/devtest/devtest.go +++ b/routers/web/devtest/devtest.go @@ -62,5 +62,5 @@ func Tmpl(ctx *context.Context) { time.Sleep(2 * time.Second) } - ctx.HTML(http.StatusOK, base.TplName("devtest"+path.Clean("/"+ctx.Params("sub")))) + ctx.HTML(http.StatusOK, base.TplName("devtest"+path.Clean("/"+ctx.PathParam("sub")))) } diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go index 1d17f962f25ae..67f138aca9fff 100644 --- a/routers/web/explore/repo.go +++ b/routers/web/explore/repo.go @@ -37,8 +37,8 @@ type RepoSearchOptions struct { // This function is also used to render the Admin Repository Management page. func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { // Sitemap index for sitemap paths - page := int(ctx.ParamsInt64("idx")) - isSitemap := ctx.Params("idx") != "" + page := int(ctx.PathParamInt64("idx")) + isSitemap := ctx.PathParam("idx") != "" if page <= 1 { page = ctx.FormInt("page") } diff --git a/routers/web/explore/user.go b/routers/web/explore/user.go index b79a79fb2c86f..18337aff48677 100644 --- a/routers/web/explore/user.go +++ b/routers/web/explore/user.go @@ -33,8 +33,8 @@ func isKeywordValid(keyword string) bool { // RenderUserSearch render user search page func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions, tplName base.TplName) { // Sitemap index for sitemap paths - opts.Page = int(ctx.ParamsInt64("idx")) - isSitemap := ctx.Params("idx") != "" + opts.Page = int(ctx.PathParamInt64("idx")) + isSitemap := ctx.PathParam("idx") != "" if opts.Page <= 1 { opts.Page = ctx.FormInt("page") } diff --git a/routers/web/feed/render.go b/routers/web/feed/render.go index a41808c24ac67..f975fc7cb2f2f 100644 --- a/routers/web/feed/render.go +++ b/routers/web/feed/render.go @@ -9,7 +9,7 @@ import ( // RenderBranchFeed render format for branch or file func RenderBranchFeed(ctx *context.Context) { - _, _, showFeedType := GetFeedType(ctx.Params(":reponame"), ctx.Req) + _, _, showFeedType := GetFeedType(ctx.PathParam(":reponame"), ctx.Req) if ctx.Repo.TreePath == "" { ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType) } else { diff --git a/routers/web/githttp.go b/routers/web/githttp.go index 5f1dedce763a2..102c92e12094d 100644 --- a/routers/web/githttp.go +++ b/routers/web/githttp.go @@ -25,7 +25,7 @@ func requireSignIn(ctx *context.Context) { } } -func gitHTTPRouters(m *web.Route) { +func gitHTTPRouters(m *web.Router) { m.Group("", func() { m.Methods("POST,OPTIONS", "/git-upload-pack", repo.ServiceUploadPack) m.Methods("POST,OPTIONS", "/git-receive-pack", repo.ServiceReceivePack) diff --git a/routers/web/org/home.go b/routers/web/org/home.go index 846b1de18ab13..c3fc4e099a4b3 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -28,14 +28,14 @@ const ( // Home show organization home page func Home(ctx *context.Context) { - uname := ctx.Params(":username") + uname := ctx.PathParam(":username") if strings.HasSuffix(uname, ".keys") || strings.HasSuffix(uname, ".gpg") { ctx.NotFound("", nil) return } - ctx.SetParams(":org", uname) + ctx.SetPathParam(":org", uname) context.HandleOrgAssignment(ctx) if ctx.Written() { return diff --git a/routers/web/org/members.go b/routers/web/org/members.go index 63ac57cf0dc4c..58d0b9b8c4048 100644 --- a/routers/web/org/members.go +++ b/routers/web/org/members.go @@ -90,7 +90,7 @@ func MembersAction(ctx *context.Context) { org := ctx.Org.Organization - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "private": if ctx.Doer.ID != member.ID && !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) @@ -131,7 +131,7 @@ func MembersAction(ctx *context.Context) { } if err != nil { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -140,7 +140,7 @@ func MembersAction(ctx *context.Context) { } redirect := ctx.Org.OrgLink + "/members" - if ctx.Params(":action") == "leave" { + if ctx.PathParam(":action") == "leave" { redirect = setting.AppSubURL + "/" } diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index 9ab3c21cb2482..eea539f6d9fb5 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -194,7 +194,7 @@ func NewProjectPost(ctx *context.Context) { // ChangeProjectStatus updates the status of a project between "open" and "close" func ChangeProjectStatus(ctx *context.Context) { var toClose bool - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "open": toClose = false case "close": @@ -203,7 +203,7 @@ func ChangeProjectStatus(ctx *context.Context) { ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects") return } - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, 0, id, toClose); err != nil { ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err) @@ -214,7 +214,7 @@ func ChangeProjectStatus(ctx *context.Context) { // DeleteProject delete a project func DeleteProject(ctx *context.Context) { - p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return @@ -243,7 +243,7 @@ func RenderEditProject(ctx *context.Context) { shared_user.RenderUserHeader(ctx) - p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return @@ -267,7 +267,7 @@ func RenderEditProject(ctx *context.Context) { // EditProjectPost response for editing a project func EditProjectPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.CreateProjectForm) - projectID := ctx.ParamsInt64(":id") + projectID := ctx.PathParamInt64(":id") ctx.Data["Title"] = ctx.Tr("repo.projects.edit") ctx.Data["PageIsEditProjects"] = true ctx.Data["PageIsViewProjects"] = true @@ -316,7 +316,7 @@ func EditProjectPost(ctx *context.Context) { // ViewProject renders the project with board view for a project func ViewProject(ctx *context.Context) { - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return @@ -398,18 +398,18 @@ func DeleteProjectColumn(ctx *context.Context) { return } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return } - pb, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { ctx.ServerError("GetProjectColumn", err) return } - if pb.ProjectID != ctx.ParamsInt64(":id") { + if pb.ProjectID != ctx.PathParamInt64(":id") { ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ "message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID), }) @@ -423,7 +423,7 @@ func DeleteProjectColumn(ctx *context.Context) { return } - if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":columnID")); err != nil { + if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil { ctx.ServerError("DeleteProjectColumnByID", err) return } @@ -435,7 +435,7 @@ func DeleteProjectColumn(ctx *context.Context) { func AddColumnToProjectPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.EditProjectColumnForm) - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return @@ -463,18 +463,18 @@ func CheckProjectColumnChangePermissions(ctx *context.Context) (*project_model.P return nil, nil } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return nil, nil } - column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { ctx.ServerError("GetProjectColumn", err) return nil, nil } - if column.ProjectID != ctx.ParamsInt64(":id") { + if column.ProjectID != ctx.PathParamInt64(":id") { ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ "message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID), }) @@ -538,7 +538,7 @@ func MoveIssues(ctx *context.Context) { return } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return @@ -548,7 +548,7 @@ func MoveIssues(ctx *context.Context) { return } - column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { ctx.NotFoundOrServerError("GetProjectColumn", project_model.IsErrProjectColumnNotExist, err) return diff --git a/routers/web/org/projects_test.go b/routers/web/org/projects_test.go index ab419cc8789bc..c52cb7ed4ce98 100644 --- a/routers/web/org/projects_test.go +++ b/routers/web/org/projects_test.go @@ -18,8 +18,8 @@ func TestCheckProjectColumnChangePermissions(t *testing.T) { ctx, _ := contexttest.MockContext(t, "user2/-/projects/4/4") contexttest.LoadUser(t, ctx, 2) ctx.ContextUser = ctx.Doer // user2 - ctx.SetParams(":id", "4") - ctx.SetParams(":columnID", "4") + ctx.SetPathParam(":id", "4") + ctx.SetPathParam(":columnID", "4") project, column := org.CheckProjectColumnChangePermissions(ctx) assert.NotNil(t, project) diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 144d9b1b43dd7..aaac1177ae1f1 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -72,7 +72,7 @@ func Teams(ctx *context.Context) { func TeamsAction(ctx *context.Context) { page := ctx.FormString("page") var err error - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "join": if !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) @@ -85,7 +85,7 @@ func TeamsAction(ctx *context.Context) { if org_model.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -112,7 +112,7 @@ func TeamsAction(ctx *context.Context) { if org_model.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -179,7 +179,7 @@ func TeamsAction(ctx *context.Context) { } if err := org_model.RemoveInviteByID(ctx, iid, ctx.Org.Team.ID); err != nil { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.ServerError("RemoveInviteByID", err) return } @@ -193,7 +193,7 @@ func TeamsAction(ctx *context.Context) { } else if errors.Is(err, user_model.ErrBlockedUser) { ctx.Flash.Error(ctx.Tr("org.teams.members.blocked_user")) } else { - log.Error("Action(%s): %v", ctx.Params(":action"), err) + log.Error("Action(%s): %v", ctx.PathParam(":action"), err) ctx.JSON(http.StatusOK, map[string]any{ "ok": false, "err": err.Error(), @@ -234,7 +234,7 @@ func TeamsRepoAction(ctx *context.Context) { } var err error - action := ctx.Params(":action") + action := ctx.PathParam(":action") switch action { case "add": repoName := path.Base(ctx.FormString("repo_name")) @@ -259,7 +259,7 @@ func TeamsRepoAction(ctx *context.Context) { } if err != nil { - log.Error("Action(%s): '%s' %v", ctx.Params(":action"), ctx.Org.Team.Name, err) + log.Error("Action(%s): '%s' %v", ctx.PathParam(":action"), ctx.Org.Team.Name, err) ctx.ServerError("TeamsRepoAction", err) return } @@ -606,7 +606,7 @@ func TeamInvitePost(ctx *context.Context) { } func getTeamInviteFromContext(ctx *context.Context) (*org_model.TeamInvite, *org_model.Organization, *org_model.Team, *user_model.User, error) { - invite, err := org_model.GetInviteByToken(ctx, ctx.Params("token")) + invite, err := org_model.GetInviteByToken(ctx, ctx.PathParam("token")) if err != nil { return nil, nil, nil, nil, err } diff --git a/routers/web/repo/actions/badge.go b/routers/web/repo/actions/badge.go index 6fa951826c31b..e920ecaf58063 100644 --- a/routers/web/repo/actions/badge.go +++ b/routers/web/repo/actions/badge.go @@ -17,7 +17,7 @@ import ( ) func GetWorkflowBadge(ctx *context.Context) { - workflowFile := ctx.Params("workflow_name") + workflowFile := ctx.PathParam("workflow_name") branch := ctx.Req.URL.Query().Get("branch") if branch == "" { branch = ctx.Repo.Repository.DefaultBranch diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 7cc12c90e6275..2c62c8d9ec0fa 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -35,8 +35,8 @@ import ( func View(ctx *context_module.Context) { ctx.Data["PageIsActions"] = true - runIndex := ctx.ParamsInt64("run") - jobIndex := ctx.ParamsInt64("job") + runIndex := ctx.PathParamInt64("run") + jobIndex := ctx.PathParamInt64("job") ctx.Data["RunIndex"] = runIndex ctx.Data["JobIndex"] = jobIndex ctx.Data["ActionsURL"] = ctx.Repo.RepoLink + "/actions" @@ -130,8 +130,8 @@ type ViewStepLogLine struct { func ViewPost(ctx *context_module.Context) { req := web.GetForm(ctx).(*ViewRequest) - runIndex := ctx.ParamsInt64("run") - jobIndex := ctx.ParamsInt64("job") + runIndex := ctx.PathParamInt64("run") + jobIndex := ctx.PathParamInt64("job") current, jobs := getRunJobs(ctx, runIndex, jobIndex) if ctx.Written() { @@ -268,8 +268,8 @@ func ViewPost(ctx *context_module.Context) { // Rerun will rerun jobs in the given run // If jobIndexStr is a blank string, it means rerun all jobs func Rerun(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") - jobIndexStr := ctx.Params("job") + runIndex := ctx.PathParamInt64("run") + jobIndexStr := ctx.PathParam("job") var jobIndex int64 if jobIndexStr != "" { jobIndex, _ = strconv.ParseInt(jobIndexStr, 10, 64) @@ -358,8 +358,8 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou } func Logs(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") - jobIndex := ctx.ParamsInt64("job") + runIndex := ctx.PathParamInt64("run") + jobIndex := ctx.PathParamInt64("job") job, _ := getRunJobs(ctx, runIndex, jobIndex) if ctx.Written() { @@ -407,7 +407,7 @@ func Logs(ctx *context_module.Context) { } func Cancel(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") + runIndex := ctx.PathParamInt64("run") _, jobs := getRunJobs(ctx, runIndex, -1) if ctx.Written() { @@ -448,7 +448,7 @@ func Cancel(ctx *context_module.Context) { } func Approve(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") + runIndex := ctx.PathParamInt64("run") current, jobs := getRunJobs(ctx, runIndex, -1) if ctx.Written() { @@ -529,7 +529,7 @@ type ArtifactsViewItem struct { } func ArtifactsView(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") + runIndex := ctx.PathParamInt64("run") run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex) if err != nil { if errors.Is(err, util.ErrNotExist) { @@ -567,8 +567,8 @@ func ArtifactsDeleteView(ctx *context_module.Context) { return } - runIndex := ctx.ParamsInt64("run") - artifactName := ctx.Params("artifact_name") + runIndex := ctx.PathParamInt64("run") + artifactName := ctx.PathParam("artifact_name") run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex) if err != nil { @@ -585,8 +585,8 @@ func ArtifactsDeleteView(ctx *context_module.Context) { } func ArtifactsDownloadView(ctx *context_module.Context) { - runIndex := ctx.ParamsInt64("run") - artifactName := ctx.Params("artifact_name") + runIndex := ctx.PathParamInt64("run") + artifactName := ctx.PathParam("artifact_name") run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex) if err != nil { diff --git a/routers/web/repo/activity.go b/routers/web/repo/activity.go index 6f6641cc65e2a..c8fa60f77a74a 100644 --- a/routers/web/repo/activity.go +++ b/routers/web/repo/activity.go @@ -24,7 +24,7 @@ func Activity(ctx *context.Context) { ctx.Data["PageIsPulse"] = true - ctx.Data["Period"] = ctx.Params("period") + ctx.Data["Period"] = ctx.PathParam("period") timeUntil := time.Now() var timeFrom time.Time @@ -75,7 +75,7 @@ func ActivityAuthors(ctx *context.Context) { timeUntil := time.Now() var timeFrom time.Time - switch ctx.Params("period") { + switch ctx.PathParam("period") { case "daily": timeFrom = timeUntil.Add(-time.Hour * 24) case "halfweekly": diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index 6437c39a5726c..0df2efeac7d59 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -154,5 +154,5 @@ func ServeAttachment(ctx *context.Context, uuid string) { // GetAttachment serve attachments func GetAttachment(ctx *context.Context) { - ServeAttachment(ctx, ctx.Params(":uuid")) + ServeAttachment(ctx, ctx.PathParam(":uuid")) } diff --git a/routers/web/repo/cherry_pick.go b/routers/web/repo/cherry_pick.go index 088f8d889d4ab..61aff78d49810 100644 --- a/routers/web/repo/cherry_pick.go +++ b/routers/web/repo/cherry_pick.go @@ -25,8 +25,8 @@ var tplCherryPick base.TplName = "repo/editor/cherry_pick" // CherryPick handles cherrypick GETs func CherryPick(ctx *context.Context) { - ctx.Data["SHA"] = ctx.Params(":sha") - cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.Params(":sha")) + ctx.Data["SHA"] = ctx.PathParam(":sha") + cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.PathParam(":sha")) if err != nil { if git.IsErrNotExist(err) { ctx.NotFound("Missing Commit", err) @@ -38,7 +38,7 @@ func CherryPick(ctx *context.Context) { if ctx.FormString("cherry-pick-type") == "revert" { ctx.Data["CherryPickType"] = "revert" - ctx.Data["commit_summary"] = "revert " + ctx.Params(":sha") + ctx.Data["commit_summary"] = "revert " + ctx.PathParam(":sha") ctx.Data["commit_message"] = "revert " + cherryPickCommit.Message() } else { ctx.Data["CherryPickType"] = "cherry-pick" @@ -67,7 +67,7 @@ func CherryPick(ctx *context.Context) { func CherryPickPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.CherryPickForm) - sha := ctx.Params(":sha") + sha := ctx.PathParam(":sha") ctx.Data["SHA"] = sha if form.Revert { ctx.Data["CherryPickType"] = "revert" @@ -141,7 +141,7 @@ func CherryPickPost(ctx *context.Context) { if form.Revert { if err := git.GetReverseRawDiff(ctx, ctx.Repo.Repository.RepoPath(), sha, buf); err != nil { if git.IsErrNotExist(err) { - ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.Params(":sha")+" does not exist.")) + ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam(":sha")+" does not exist.")) return } ctx.ServerError("GetRawDiff", err) @@ -150,7 +150,7 @@ func CherryPickPost(ctx *context.Context) { } else { if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, git.RawDiffType("patch"), buf); err != nil { if git.IsErrNotExist(err) { - ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.Params(":sha")+" does not exist.")) + ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam(":sha")+" does not exist.")) return } ctx.ServerError("GetRawDiff", err) diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 7b5e72593f69a..dae6063908d31 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -257,12 +257,12 @@ func FileHistory(ctx *context.Context) { } func LoadBranchesAndTags(ctx *context.Context) { - response, err := git_service.LoadBranchesAndTags(ctx, ctx.Repo, ctx.Params("sha")) + response, err := git_service.LoadBranchesAndTags(ctx, ctx.Repo, ctx.PathParam("sha")) if err == nil { ctx.JSON(http.StatusOK, response) return } - ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.Params("sha")), git.IsErrNotExist, err) + ctx.NotFoundOrServerError(fmt.Sprintf("could not load branches and tags the commit %s belongs to", ctx.PathParam("sha")), git.IsErrNotExist, err) } // Diff show different from current commit to previous commit @@ -271,7 +271,7 @@ func Diff(ctx *context.Context) { userName := ctx.Repo.Owner.Name repoName := ctx.Repo.Repository.Name - commitID := ctx.Params(":sha") + commitID := ctx.PathParam(":sha") var ( gitRepo *git.Repository err error @@ -420,13 +420,13 @@ func RawDiff(ctx *context.Context) { } if err := git.GetRawDiff( gitRepo, - ctx.Params(":sha"), - git.RawDiffType(ctx.Params(":ext")), + ctx.PathParam(":sha"), + git.RawDiffType(ctx.PathParam(":ext")), ctx.Resp, ); err != nil { if git.IsErrNotExist(err) { ctx.NotFound("GetRawDiff", - errors.New("commit "+ctx.Params(":sha")+" does not exist.")) + errors.New("commit "+ctx.PathParam(":sha")+" does not exist.")) return } ctx.ServerError("GetRawDiff", err) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 818dc4d50f75c..65e23bf751cac 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -203,7 +203,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo { // 5. /{:baseOwner}/{:baseRepoName}/compare/{:headOwner}:{:headBranch} // 6. /{:baseOwner}/{:baseRepoName}/compare/{:headOwner}/{:headRepoName}:{:headBranch} // - // Here we obtain the infoPath "{:baseBranch}...[{:headOwner}/{:headRepoName}:]{:headBranch}" as ctx.Params("*") + // Here we obtain the infoPath "{:baseBranch}...[{:headOwner}/{:headRepoName}:]{:headBranch}" as ctx.PathParam("*") // with the :baseRepo in ctx.Repo. // // Note: Generally :headRepoName is not provided here - we are only passed :headOwner. @@ -225,7 +225,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo { err error ) - infoPath = ctx.Params("*") + infoPath = ctx.PathParam("*") var infos []string if infoPath == "" { infos = []string{baseRepo.DefaultBranch, baseRepo.DefaultBranch} @@ -850,7 +850,7 @@ func CompareDiff(ctx *context.Context) { // ExcerptBlob render blob excerpt contents func ExcerptBlob(ctx *context.Context) { - commitID := ctx.Params("sha") + commitID := ctx.PathParam("sha") lastLeft := ctx.FormInt("last_left") lastRight := ctx.FormInt("last_right") idxLeft := ctx.FormInt("left") diff --git a/routers/web/repo/download.go b/routers/web/repo/download.go index 802e8e6a62cb2..8c4da34060453 100644 --- a/routers/web/repo/download.go +++ b/routers/web/repo/download.go @@ -139,7 +139,7 @@ func SingleDownloadOrLFS(ctx *context.Context) { // DownloadByID download a file by sha1 ID func DownloadByID(ctx *context.Context) { - blob, err := ctx.Repo.GitRepo.GetBlob(ctx.Params("sha")) + blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha")) if err != nil { if git.IsErrNotExist(err) { ctx.NotFound("GetBlob", nil) @@ -155,7 +155,7 @@ func DownloadByID(ctx *context.Context) { // DownloadByIDOrLFS download a file by sha1 ID taking account of LFS func DownloadByIDOrLFS(ctx *context.Context) { - blob, err := ctx.Repo.GitRepo.GetBlob(ctx.Params("sha")) + blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha")) if err != nil { if git.IsErrNotExist(err) { ctx.NotFound("GetBlob", nil) diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go index 313fcfe33a28b..68d69408ac883 100644 --- a/routers/web/repo/editor_test.go +++ b/routers/web/repo/editor_test.go @@ -43,7 +43,7 @@ func TestCleanUploadName(t *testing.T) { func TestGetUniquePatchBranchName(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -58,7 +58,7 @@ func TestGetUniquePatchBranchName(t *testing.T) { func TestGetClosestParentWithFiles(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) diff --git a/routers/web/repo/find.go b/routers/web/repo/find.go index 9da4237c1edd3..2c44552f9c432 100644 --- a/routers/web/repo/find.go +++ b/routers/web/repo/find.go @@ -17,7 +17,7 @@ const ( // FindFiles render the page to find repository files func FindFiles(ctx *context.Context) { - path := ctx.Params("*") + path := ctx.PathParam("*") ctx.Data["TreeLink"] = ctx.Repo.RepoLink + "/src/" + util.PathEscapeSegments(path) ctx.Data["DataLink"] = ctx.Repo.RepoLink + "/tree-list/" + util.PathEscapeSegments(path) ctx.HTML(http.StatusOK, tplFindFiles) diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go index f0579b56ea137..bb85df1a868b8 100644 --- a/routers/web/repo/githttp.go +++ b/routers/web/repo/githttp.go @@ -57,8 +57,8 @@ func CorsHandler() func(next http.Handler) http.Handler { // httpBase implementation git smart HTTP protocol func httpBase(ctx *context.Context) *serviceHandler { - username := ctx.Params(":username") - reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") + username := ctx.PathParam(":username") + reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git") if ctx.FormString("go-get") == "1" { context.EarlyResponseForGoGetMeta(ctx) @@ -550,7 +550,7 @@ func GetTextFile(p string) func(*context.Context) { h := httpBase(ctx) if h != nil { setHeaderNoCache(ctx) - file := ctx.Params("file") + file := ctx.PathParam("file") if file != "" { h.sendFile(ctx, "text/plain", "objects/info/"+file) } else { @@ -575,7 +575,7 @@ func GetLooseObject(ctx *context.Context) { if h != nil { setHeaderCacheForever(ctx) h.sendFile(ctx, "application/x-git-loose-object", fmt.Sprintf("objects/%s/%s", - ctx.Params("head"), ctx.Params("hash"))) + ctx.PathParam("head"), ctx.PathParam("hash"))) } } @@ -584,7 +584,7 @@ func GetPackFile(ctx *context.Context) { h := httpBase(ctx) if h != nil { setHeaderCacheForever(ctx) - h.sendFile(ctx, "application/x-git-packed-objects", "objects/pack/pack-"+ctx.Params("file")+".pack") + h.sendFile(ctx, "application/x-git-packed-objects", "objects/pack/pack-"+ctx.PathParam("file")+".pack") } } @@ -593,6 +593,6 @@ func GetIdxFile(ctx *context.Context) { h := httpBase(ctx) if h != nil { setHeaderCacheForever(ctx) - h.sendFile(ctx, "application/x-git-packed-objects-toc", "objects/pack/pack-"+ctx.Params("file")+".idx") + h.sendFile(ctx, "application/x-git-packed-objects-toc", "objects/pack/pack-"+ctx.PathParam("file")+".idx") } } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index e7ad02c0c25ec..7c4e3e36f3caa 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -495,7 +495,7 @@ func issueIDsFromSearch(ctx *context.Context, keyword string, opts *issues_model // Issues render issues page func Issues(ctx *context.Context) { - isPullList := ctx.Params(":type") == "pulls" + isPullList := ctx.PathParam(":type") == "pulls" if isPullList { MustAllowPulls(ctx) if ctx.Written() { @@ -1365,13 +1365,13 @@ func getBranchData(ctx *context.Context, issue *issues_model.Issue) { // ViewIssue render issue view page func ViewIssue(ctx *context.Context) { - if ctx.Params(":type") == "issues" { + if ctx.PathParam(":type") == "issues" { // If issue was requested we check if repo has external tracker and redirect extIssueUnit, err := ctx.Repo.Repository.GetUnit(ctx, unit.TypeExternalTracker) if err == nil && extIssueUnit != nil { if extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == markup.IssueNameStyleNumeric || extIssueUnit.ExternalTrackerConfig().ExternalTrackerStyle == "" { metas := ctx.Repo.Repository.ComposeMetas(ctx) - metas["index"] = ctx.Params(":index") + metas["index"] = ctx.PathParam(":index") res, err := vars.Expand(extIssueUnit.ExternalTrackerConfig().ExternalTrackerFormat, metas) if err != nil { log.Error("unable to expand template vars for issue url. issue: %s, err: %v", metas["index"], err) @@ -1387,7 +1387,7 @@ func ViewIssue(ctx *context.Context) { } } - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound("GetIssueByIndex", err) @@ -1401,10 +1401,10 @@ func ViewIssue(ctx *context.Context) { } // Make sure type and URL matches. - if ctx.Params(":type") == "issues" && issue.IsPull { + if ctx.PathParam(":type") == "issues" && issue.IsPull { ctx.Redirect(issue.Link()) return - } else if ctx.Params(":type") == "pulls" && !issue.IsPull { + } else if ctx.PathParam(":type") == "pulls" && !issue.IsPull { ctx.Redirect(issue.Link()) return } @@ -2092,7 +2092,7 @@ func sortDependencyInfo(blockers []*issues_model.DependencyInfo) { // GetActionIssue will return the issue which is used in the context. func GetActionIssue(ctx *context.Context) *issues_model.Issue { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { ctx.NotFoundOrServerError("GetIssueByIndex", issues_model.IsErrIssueNotExist, err) return nil @@ -2157,7 +2157,7 @@ func getActionIssues(ctx *context.Context) issues_model.IssueList { // GetIssueInfo get an issue of a repository func GetIssueInfo(ctx *context.Context) { - issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.Error(http.StatusNotFound) @@ -2298,7 +2298,7 @@ func UpdateIssueContent(ctx *context.Context) { // UpdateIssueDeadline updates an issue deadline func UpdateIssueDeadline(ctx *context.Context) { form := web.GetForm(ctx).(*api.EditDeadlineOption) - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound("GetIssueByIndex", err) @@ -3137,7 +3137,7 @@ func NewComment(ctx *context.Context) { // UpdateCommentContent change comment of issue's content func UpdateCommentContent(ctx *context.Context) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err) return @@ -3222,7 +3222,7 @@ func UpdateCommentContent(ctx *context.Context) { // DeleteComment delete comment of issue func DeleteComment(ctx *context.Context) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err) return @@ -3290,7 +3290,7 @@ func ChangeIssueReaction(ctx *context.Context) { return } - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "react": reaction, err := issue_service.CreateIssueReaction(ctx, ctx.Doer, issue, form.Content) if err != nil { @@ -3324,7 +3324,7 @@ func ChangeIssueReaction(ctx *context.Context) { log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID) default: - ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil) + ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil) return } @@ -3352,7 +3352,7 @@ func ChangeIssueReaction(ctx *context.Context) { // ChangeCommentReaction create a reaction for comment func ChangeCommentReaction(ctx *context.Context) { form := web.GetForm(ctx).(*forms.ReactionForm) - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err) return @@ -3396,7 +3396,7 @@ func ChangeCommentReaction(ctx *context.Context) { return } - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "react": reaction, err := issue_service.CreateCommentReaction(ctx, ctx.Doer, comment, form.Content) if err != nil { @@ -3430,7 +3430,7 @@ func ChangeCommentReaction(ctx *context.Context) { log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID) default: - ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.Params(":action")), nil) + ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam(":action")), nil) return } @@ -3504,7 +3504,7 @@ func GetIssueAttachments(ctx *context.Context) { // GetCommentAttachments returns attachments for the comment func GetCommentAttachments(ctx *context.Context) { - comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id")) + comment, err := issues_model.GetCommentByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetCommentByID", issues_model.IsErrCommentNotExist, err) return diff --git a/routers/web/repo/issue_dependency.go b/routers/web/repo/issue_dependency.go index e3b85ee638e93..f1d133edb0064 100644 --- a/routers/web/repo/issue_dependency.go +++ b/routers/web/repo/issue_dependency.go @@ -14,7 +14,7 @@ import ( // AddDependency adds new dependencies func AddDependency(ctx *context.Context) { - issueIndex := ctx.ParamsInt64("index") + issueIndex := ctx.PathParamInt64("index") issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex) if err != nil { ctx.ServerError("GetIssueByIndex", err) @@ -88,7 +88,7 @@ func AddDependency(ctx *context.Context) { // RemoveDependency removes the dependency func RemoveDependency(ctx *context.Context) { - issueIndex := ctx.ParamsInt64("index") + issueIndex := ctx.PathParamInt64("index") issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex) if err != nil { ctx.ServerError("GetIssueByIndex", err) diff --git a/routers/web/repo/issue_pin.go b/routers/web/repo/issue_pin.go index 365c812681a22..0074e31f038d9 100644 --- a/routers/web/repo/issue_pin.go +++ b/routers/web/repo/issue_pin.go @@ -39,7 +39,7 @@ func IssuePinOrUnpin(ctx *context.Context) { // IssueUnpin unpins a Issue func IssueUnpin(ctx *context.Context) { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { ctx.Status(http.StatusInternalServerError) log.Error(err.Error()) diff --git a/routers/web/repo/issue_timetrack.go b/routers/web/repo/issue_timetrack.go index 241e434049900..099711c5e9cf8 100644 --- a/routers/web/repo/issue_timetrack.go +++ b/routers/web/repo/issue_timetrack.go @@ -61,7 +61,7 @@ func DeleteTime(c *context.Context) { return } - t, err := issues_model.GetTrackedTimeByID(c, c.ParamsInt64(":timeid")) + t, err := issues_model.GetTrackedTimeByID(c, c.PathParamInt64(":timeid")) if err != nil { if db.IsErrNotExist(err) { c.NotFound("time not found", err) diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index c6c8cb5cfbd01..e4ee025875ef6 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -165,7 +165,7 @@ func EditMilestone(ctx *context.Context) { ctx.Data["PageIsMilestones"] = true ctx.Data["PageIsEditMilestone"] = true - m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrMilestoneNotExist(err) { ctx.NotFound("", nil) @@ -205,7 +205,7 @@ func EditMilestonePost(ctx *context.Context) { } deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location()) - m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")) if err != nil { if issues_model.IsErrMilestoneNotExist(err) { ctx.NotFound("", nil) @@ -229,7 +229,7 @@ func EditMilestonePost(ctx *context.Context) { // ChangeMilestoneStatus response for change a milestone's status func ChangeMilestoneStatus(ctx *context.Context) { var toClose bool - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "open": toClose = false case "close": @@ -238,7 +238,7 @@ func ChangeMilestoneStatus(ctx *context.Context) { ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones") return } - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil { if issues_model.IsErrMilestoneNotExist(err) { @@ -248,7 +248,7 @@ func ChangeMilestoneStatus(ctx *context.Context) { } return } - ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action"))) + ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.PathParam(":action"))) } // DeleteMilestone delete a milestone @@ -264,7 +264,7 @@ func DeleteMilestone(ctx *context.Context) { // MilestoneIssuesAndPulls lists all the issues and pull requests of the milestone func MilestoneIssuesAndPulls(ctx *context.Context) { - milestoneID := ctx.ParamsInt64(":id") + milestoneID := ctx.PathParamInt64(":id") projectID := ctx.FormInt64("project") milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID) if err != nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 2e32f478aabf4..fdeead57035a7 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -170,7 +170,7 @@ func NewProjectPost(ctx *context.Context) { // ChangeProjectStatus updates the status of a project between "open" and "close" func ChangeProjectStatus(ctx *context.Context) { var toClose bool - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "open": toClose = false case "close": @@ -179,7 +179,7 @@ func ChangeProjectStatus(ctx *context.Context) { ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects") return } - id := ctx.ParamsInt64(":id") + id := ctx.PathParamInt64(":id") if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil { ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err) @@ -190,7 +190,7 @@ func ChangeProjectStatus(ctx *context.Context) { // DeleteProject delete a project func DeleteProject(ctx *context.Context) { - p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -220,7 +220,7 @@ func RenderEditProject(ctx *context.Context) { ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects) ctx.Data["CardTypes"] = project_model.GetCardConfig() - p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -247,7 +247,7 @@ func RenderEditProject(ctx *context.Context) { // EditProjectPost response for editing a project func EditProjectPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.CreateProjectForm) - projectID := ctx.ParamsInt64(":id") + projectID := ctx.PathParamInt64(":id") ctx.Data["Title"] = ctx.Tr("repo.projects.edit") ctx.Data["PageIsEditProjects"] = true @@ -292,7 +292,7 @@ func EditProjectPost(ctx *context.Context) { // ViewProject renders the project with board view func ViewProject(ctx *context.Context) { - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -424,7 +424,7 @@ func DeleteProjectColumn(ctx *context.Context) { return } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -434,12 +434,12 @@ func DeleteProjectColumn(ctx *context.Context) { return } - pb, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + pb, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { ctx.ServerError("GetProjectColumn", err) return } - if pb.ProjectID != ctx.ParamsInt64(":id") { + if pb.ProjectID != ctx.PathParamInt64(":id") { ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ "message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", pb.ID, project.ID), }) @@ -453,7 +453,7 @@ func DeleteProjectColumn(ctx *context.Context) { return } - if err := project_model.DeleteColumnByID(ctx, ctx.ParamsInt64(":columnID")); err != nil { + if err := project_model.DeleteColumnByID(ctx, ctx.PathParamInt64(":columnID")); err != nil { ctx.ServerError("DeleteProjectColumnByID", err) return } @@ -471,7 +471,7 @@ func AddColumnToProjectPost(ctx *context.Context) { return } - project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -509,7 +509,7 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P return nil, nil } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("", nil) @@ -519,12 +519,12 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P return nil, nil } - column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { ctx.ServerError("GetProjectColumn", err) return nil, nil } - if column.ProjectID != ctx.ParamsInt64(":id") { + if column.ProjectID != ctx.PathParamInt64(":id") { ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ "message": fmt.Sprintf("ProjectColumn[%d] is not in Project[%d] as expected", column.ID, project.ID), }) @@ -595,7 +595,7 @@ func MoveIssues(ctx *context.Context) { return } - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { if project_model.IsErrProjectNotExist(err) { ctx.NotFound("ProjectNotExist", nil) @@ -609,7 +609,7 @@ func MoveIssues(ctx *context.Context) { return } - column, err := project_model.GetColumn(ctx, ctx.ParamsInt64(":columnID")) + column, err := project_model.GetColumn(ctx, ctx.PathParamInt64(":columnID")) if err != nil { if project_model.IsErrProjectColumnNotExist(err) { ctx.NotFound("ProjectColumnNotExist", nil) diff --git a/routers/web/repo/projects_test.go b/routers/web/repo/projects_test.go index d61230a57e6be..1a42c615abc55 100644 --- a/routers/web/repo/projects_test.go +++ b/routers/web/repo/projects_test.go @@ -17,8 +17,8 @@ func TestCheckProjectColumnChangePermissions(t *testing.T) { ctx, _ := contexttest.MockContext(t, "user2/repo1/projects/1/2") contexttest.LoadUser(t, ctx, 2) contexttest.LoadRepo(t, ctx, 1) - ctx.SetParams(":id", "1") - ctx.SetParams(":columnID", "2") + ctx.SetPathParam(":id", "1") + ctx.SetPathParam(":columnID", "2") project, column := checkProjectColumnChangePermissions(ctx) assert.NotNil(t, project) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 92e0a1674e080..45220994604e1 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -108,7 +108,7 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository { } func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) { - issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrIssueNotExist(err) { ctx.NotFound("GetIssueByIndex", err) @@ -886,15 +886,15 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi } func ViewPullFilesForSingleCommit(ctx *context.Context) { - viewPullFiles(ctx, "", ctx.Params("sha"), true, true) + viewPullFiles(ctx, "", ctx.PathParam("sha"), true, true) } func ViewPullFilesForRange(ctx *context.Context) { - viewPullFiles(ctx, ctx.Params("shaFrom"), ctx.Params("shaTo"), true, false) + viewPullFiles(ctx, ctx.PathParam("shaFrom"), ctx.PathParam("shaTo"), true, false) } func ViewPullFilesStartingFromCommit(ctx *context.Context) { - viewPullFiles(ctx, "", ctx.Params("sha"), true, false) + viewPullFiles(ctx, "", ctx.PathParam("sha"), true, false) } func ViewPullFilesForAllCommitsOfPr(ctx *context.Context) { @@ -1493,7 +1493,7 @@ func DownloadPullPatch(ctx *context.Context) { // DownloadPullDiffOrPatch render a pull's raw diff or patch func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) { - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) @@ -1586,7 +1586,7 @@ func UpdatePullRequestTarget(ctx *context.Context) { func SetAllowEdits(ctx *context.Context) { form := web.GetForm(ctx).(*forms.UpdateAllowEditsForm) - pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) + pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64(":index")) if err != nil { if issues_model.IsErrPullRequestNotExist(err) { ctx.NotFound("GetPullRequestByIndex", err) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 8ba2adf3f136e..85c7828f2e404 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -286,7 +286,7 @@ func SingleRelease(ctx *context.Context) { releases, err := getReleaseInfos(ctx, &repo_model.FindReleasesOptions{ ListOptions: db.ListOptions{Page: 1, PageSize: 1}, RepoID: ctx.Repo.Repository.ID, - TagNames: []string{ctx.Params("*")}, + TagNames: []string{ctx.PathParam("*")}, // only show draft releases for users who can write, read-only users shouldn't see draft releases. IncludeDrafts: writeAccess, IncludeTags: true, @@ -528,7 +528,7 @@ func EditRelease(ctx *context.Context) { ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "release") - tagName := ctx.Params("*") + tagName := ctx.PathParam("*") rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName) if err != nil { if repo_model.IsErrReleaseNotExist(err) { @@ -571,7 +571,7 @@ func EditReleasePost(ctx *context.Context) { ctx.Data["PageIsReleaseList"] = true ctx.Data["PageIsEditRelease"] = true - tagName := ctx.Params("*") + tagName := ctx.PathParam("*") rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName) if err != nil { if repo_model.IsErrReleaseNotExist(err) { diff --git a/routers/web/repo/render.go b/routers/web/repo/render.go index e64db03e2015e..6aba9e0ac1436 100644 --- a/routers/web/repo/render.go +++ b/routers/web/repo/render.go @@ -47,7 +47,7 @@ func RenderFile(ctx *context.Context) { rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) ctx.Resp.Header().Add("Content-Security-Policy", "frame-src 'self'; sandbox allow-scripts") - if markupType := markup.Type(blob.Name()); markupType == "" { + if markupType := markup.DetectMarkupTypeByFileName(blob.Name()); markupType == "" { if isTextFile { _, _ = io.Copy(ctx.Resp, rd) } else { diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 92f74bbf333c1..70dcbae0e17c8 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -312,7 +312,7 @@ const ( // Action response for actions to a repository func Action(ctx *context.Context) { var err error - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "watch": err = repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, true) case "unwatch": @@ -340,29 +340,29 @@ func Action(ctx *context.Context) { if errors.Is(err, user_model.ErrBlockedUser) { ctx.Flash.Error(ctx.Tr("repo.action.blocked_user")) } else { - ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Params(":action")), err) + ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err) return } } - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "watch", "unwatch": ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) case "star", "unstar": ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) } - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "watch", "unwatch", "star", "unstar": // we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name) if err != nil { - ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Params(":action")), err) + ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam(":action")), err) return } } - switch ctx.Params(":action") { + switch ctx.PathParam(":action") { case "watch", "unwatch": ctx.HTML(http.StatusOK, tplWatchUnwatch) return @@ -412,8 +412,8 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error { // RedirectDownload return a file based on the following infos: func RedirectDownload(ctx *context.Context) { var ( - vTag = ctx.Params("vTag") - fileName = ctx.Params("fileName") + vTag = ctx.PathParam("vTag") + fileName = ctx.PathParam("fileName") ) tagNames := []string{vTag} curRepo := ctx.Repo.Repository @@ -460,7 +460,7 @@ func RedirectDownload(ctx *context.Context) { // Download an archive of a repository func Download(ctx *context.Context) { - uri := ctx.Params("*") + uri := ctx.PathParam("*") aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri) if err != nil { if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) { @@ -519,7 +519,7 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep // a request that's already in-progress, but the archiver service will just // kind of drop it on the floor if this is the case. func InitiateDownload(ctx *context.Context) { - uri := ctx.Params("*") + uri := ctx.PathParam("*") aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, uri) if err != nil { ctx.ServerError("archiver_service.NewRequest", err) diff --git a/routers/web/repo/setting/git_hooks.go b/routers/web/repo/setting/git_hooks.go index 217a01c90c1cb..2e9caa4c868f1 100644 --- a/routers/web/repo/setting/git_hooks.go +++ b/routers/web/repo/setting/git_hooks.go @@ -30,7 +30,7 @@ func GitHooksEdit(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["PageIsSettingsGitHooks"] = true - name := ctx.Params(":name") + name := ctx.PathParam(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) if err != nil { if err == git.ErrNotValidHook { @@ -46,7 +46,7 @@ func GitHooksEdit(ctx *context.Context) { // GitHooksEditPost response for editing a git hook of a repository func GitHooksEditPost(ctx *context.Context) { - name := ctx.Params(":name") + name := ctx.PathParam(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) if err != nil { if err == git.ErrNotValidHook { diff --git a/routers/web/repo/setting/lfs.go b/routers/web/repo/setting/lfs.go index 2891556d6fc30..3b96f93ff2f71 100644 --- a/routers/web/repo/setting/lfs.go +++ b/routers/web/repo/setting/lfs.go @@ -236,7 +236,7 @@ func LFSUnlock(ctx *context.Context) { ctx.NotFound("LFSUnlock", nil) return } - _, err := git_model.DeleteLFSLockByID(ctx, ctx.ParamsInt64("lid"), ctx.Repo.Repository, ctx.Doer, true) + _, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), ctx.Repo.Repository, ctx.Doer, true) if err != nil { ctx.ServerError("LFSUnlock", err) return @@ -251,7 +251,7 @@ func LFSFileGet(ctx *context.Context) { return } ctx.Data["LFSFilesLink"] = ctx.Repo.RepoLink + "/settings/lfs" - oid := ctx.Params("oid") + oid := ctx.PathParam("oid") p := lfs.Pointer{Oid: oid} if !p.IsValid() { @@ -348,7 +348,7 @@ func LFSDelete(ctx *context.Context) { ctx.NotFound("LFSDelete", nil) return } - oid := ctx.Params("oid") + oid := ctx.PathParam("oid") p := lfs.Pointer{Oid: oid} if !p.IsValid() { ctx.NotFound("LFSDelete", nil) diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go index 4bab3f897a20a..400186db671a5 100644 --- a/routers/web/repo/setting/protected_branch.go +++ b/routers/web/repo/setting/protected_branch.go @@ -266,7 +266,7 @@ func SettingsProtectedBranchPost(ctx *context.Context) { // DeleteProtectedBranchRulePost delete protected branch rule by id func DeleteProtectedBranchRulePost(ctx *context.Context) { - ruleID := ctx.ParamsInt64("id") + ruleID := ctx.PathParamInt64("id") if ruleID <= 0 { ctx.Flash.Error(ctx.Tr("repo.settings.remove_protected_branch_failed", fmt.Sprintf("%d", ruleID))) ctx.JSONRedirect(fmt.Sprintf("%s/settings/branches", ctx.Repo.RepoLink)) diff --git a/routers/web/repo/setting/protected_tag.go b/routers/web/repo/setting/protected_tag.go index 2c25b650b977e..fcfa77aa8ce04 100644 --- a/routers/web/repo/setting/protected_tag.go +++ b/routers/web/repo/setting/protected_tag.go @@ -169,7 +169,7 @@ func setTagsContext(ctx *context.Context) error { func selectProtectedTagByContext(ctx *context.Context) *git_model.ProtectedTag { id := ctx.FormInt64("id") if id == 0 { - id = ctx.ParamsInt64(":id") + id = ctx.PathParamInt64(":id") } tag, err := git_model.GetProtectedTagByID(ctx, id) diff --git a/routers/web/repo/setting/runners.go b/routers/web/repo/setting/runners.go index a47d3b45e2cb5..93e6f518b0bed 100644 --- a/routers/web/repo/setting/runners.go +++ b/routers/web/repo/setting/runners.go @@ -147,7 +147,7 @@ func RunnersEdit(ctx *context.Context) { } actions_shared.RunnerDetails(ctx, page, - ctx.ParamsInt64(":runnerid"), rCtx.OwnerID, rCtx.RepoID, + ctx.PathParamInt64(":runnerid"), rCtx.OwnerID, rCtx.RepoID, ) ctx.HTML(http.StatusOK, rCtx.RunnerEditTemplate) } @@ -158,9 +158,9 @@ func RunnersEditPost(ctx *context.Context) { ctx.ServerError("getRunnersCtx", err) return } - actions_shared.RunnerDetailsEditPost(ctx, ctx.ParamsInt64(":runnerid"), + actions_shared.RunnerDetailsEditPost(ctx, ctx.PathParamInt64(":runnerid"), rCtx.OwnerID, rCtx.RepoID, - rCtx.RedirectLink+url.PathEscape(ctx.Params(":runnerid"))) + rCtx.RedirectLink+url.PathEscape(ctx.PathParam(":runnerid"))) } func ResetRunnerRegistrationToken(ctx *context.Context) { @@ -179,7 +179,7 @@ func RunnerDeletePost(ctx *context.Context) { ctx.ServerError("getRunnersCtx", err) return } - actions_shared.RunnerDeletePost(ctx, ctx.ParamsInt64(":runnerid"), rCtx.RedirectLink, rCtx.RedirectLink+url.PathEscape(ctx.Params(":runnerid"))) + actions_shared.RunnerDeletePost(ctx, ctx.PathParamInt64(":runnerid"), rCtx.RedirectLink, rCtx.RedirectLink+url.PathEscape(ctx.PathParam(":runnerid"))) } func RedirectToDefaultSetting(ctx *context.Context) { diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index 1a3549fea4110..76615997296c6 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -99,9 +99,9 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) { if ctx.Data["PageIsAdmin"] == true { return &ownerRepoCtx{ IsAdmin: true, - IsSystemWebhook: ctx.Params(":configType") == "system-hooks", + IsSystemWebhook: ctx.PathParam(":configType") == "system-hooks", Link: path.Join(setting.AppSubURL, "/admin/hooks"), - LinkNew: path.Join(setting.AppSubURL, "/admin/", ctx.Params(":configType")), + LinkNew: path.Join(setting.AppSubURL, "/admin/", ctx.PathParam(":configType")), NewTemplate: tplAdminHookNew, }, nil } @@ -110,7 +110,7 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) { } func checkHookType(ctx *context.Context) string { - hookType := strings.ToLower(ctx.Params(":type")) + hookType := strings.ToLower(ctx.PathParam(":type")) if !util.SliceContainsString(setting.Webhook.Types, hookType, true) { ctx.NotFound("checkHookType", nil) return "" @@ -592,11 +592,11 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) { var w *webhook.Webhook if orCtx.RepoID > 0 { - w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.ParamsInt64(":id")) + w, err = webhook.GetWebhookByRepoID(ctx, orCtx.RepoID, ctx.PathParamInt64(":id")) } else if orCtx.OwnerID > 0 { - w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.ParamsInt64(":id")) + w, err = webhook.GetWebhookByOwnerID(ctx, orCtx.OwnerID, ctx.PathParamInt64(":id")) } else if orCtx.IsAdmin { - w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.ParamsInt64(":id")) + w, err = webhook.GetSystemOrDefaultWebhook(ctx, ctx.PathParamInt64(":id")) } if err != nil || w == nil { if webhook.IsErrWebhookNotExist(err) { @@ -645,7 +645,7 @@ func WebHooksEdit(ctx *context.Context) { // TestWebhook test if web hook is work fine func TestWebhook(ctx *context.Context) { - hookID := ctx.ParamsInt64(":id") + hookID := ctx.PathParamInt64(":id") w, err := webhook.GetWebhookByRepoID(ctx, ctx.Repo.Repository.ID, hookID) if err != nil { ctx.Flash.Error("GetWebhookByRepoID: " + err.Error()) @@ -706,7 +706,7 @@ func TestWebhook(ctx *context.Context) { // ReplayWebhook replays a webhook func ReplayWebhook(ctx *context.Context) { - hookTaskUUID := ctx.Params(":uuid") + hookTaskUUID := ctx.PathParam(":uuid") orCtx, w := checkWebhook(ctx) if ctx.Written() { diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 0aa3fe1efd77b..203dac74397e0 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -307,7 +307,7 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) - if markupType := markup.Type(readmeFile.Name()); markupType != "" { + if markupType := markup.DetectMarkupTypeByFileName(readmeFile.Name()); markupType != "" { ctx.Data["IsMarkup"] = true ctx.Data["MarkupType"] = markupType @@ -499,7 +499,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) { readmeExist := util.IsReadmeFileName(blob.Name()) ctx.Data["ReadmeExist"] = readmeExist - markupType := markup.Type(blob.Name()) + markupType := markup.DetectMarkupTypeByFileName(blob.Name()) // If the markup is detected by custom markup renderer it should not be reset later on // to not pass it down to the render context. detected := false @@ -607,7 +607,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) { // TODO: this logic duplicates with "isRepresentableAsText=true", it is not the same as "LFSFileGet" in "lfs.go" // It is used by "external renders", markupRender will execute external programs to get rendered content. - if markupType := markup.Type(blob.Name()); markupType != "" { + if markupType := markup.DetectMarkupTypeByFileName(blob.Name()); markupType != "" { rd := io.MultiReader(bytes.NewReader(buf), dataRc) ctx.Data["IsMarkup"] = true ctx.Data["MarkupType"] = markupType @@ -772,7 +772,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) { // Home render repository home page func Home(ctx *context.Context) { if setting.Other.EnableFeed { - isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req) + isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam(":reponame"), ctx.Req) if isFeed { switch { case ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType): diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index df15f61b173ff..ff6397cd2a82e 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -532,7 +532,7 @@ func Wiki(ctx *context.Context) { } wikiPath := entry.Name() - if markup.Type(wikiPath) != markdown.MarkupName { + if markup.DetectMarkupTypeByFileName(wikiPath) != markdown.MarkupName { ext := strings.ToUpper(filepath.Ext(wikiPath)) ctx.Data["FormatWarning"] = fmt.Sprintf("%s rendering is not supported at the moment. Rendered as Markdown.", ext) } diff --git a/routers/web/repo/wiki_test.go b/routers/web/repo/wiki_test.go index 4602dcfeb40e0..7de5899e21c1b 100644 --- a/routers/web/repo/wiki_test.go +++ b/routers/web/repo/wiki_test.go @@ -81,7 +81,7 @@ func TestWiki(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki") - ctx.SetParams("*", "Home") + ctx.SetPathParam("*", "Home") contexttest.LoadRepo(t, ctx, 1) Wiki(ctx) assert.EqualValues(t, http.StatusOK, ctx.Resp.Status()) @@ -153,7 +153,7 @@ func TestEditWiki(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_edit") - ctx.SetParams("*", "Home") + ctx.SetPathParam("*", "Home") contexttest.LoadUser(t, ctx, 2) contexttest.LoadRepo(t, ctx, 1) EditWiki(ctx) @@ -169,7 +169,7 @@ func TestEditWikiPost(t *testing.T) { } { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_new") - ctx.SetParams("*", "Home") + ctx.SetPathParam("*", "Home") contexttest.LoadUser(t, ctx, 2) contexttest.LoadRepo(t, ctx, 1) web.SetForm(ctx, &forms.NewWikiForm{ @@ -211,7 +211,7 @@ func TestWikiRaw(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath)) - ctx.SetParams("*", filepath) + ctx.SetPathParam("*", filepath) contexttest.LoadUser(t, ctx, 2) contexttest.LoadRepo(t, ctx, 1) WikiRaw(ctx) @@ -236,7 +236,7 @@ func TestDefaultWikiBranch(t *testing.T) { assert.NoError(t, repo_model.UpdateRepositoryCols(db.DefaultContext, &repo_model.Repository{ID: 1, DefaultWikiBranch: "wrong-branch"})) ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki") - ctx.SetParams("*", "Home") + ctx.SetPathParam("*", "Home") contexttest.LoadRepo(t, ctx, 1) assert.Equal(t, "wrong-branch", ctx.Repo.Repository.DefaultWikiBranch) Wiki(ctx) // after the visiting, the out-of-sync database record will update the branch name to "master" diff --git a/routers/web/shared/actions/variables.go b/routers/web/shared/actions/variables.go index 79c03e4e8ca21..5c5768243ab30 100644 --- a/routers/web/shared/actions/variables.go +++ b/routers/web/shared/actions/variables.go @@ -40,7 +40,7 @@ func CreateVariable(ctx *context.Context, ownerID, repoID int64, redirectURL str } func UpdateVariable(ctx *context.Context, redirectURL string) { - id := ctx.ParamsInt64(":variable_id") + id := ctx.PathParamInt64(":variable_id") form := web.GetForm(ctx).(*forms.EditVariableForm) if ok, err := actions_service.UpdateVariable(ctx, id, form.Name, form.Data); err != nil || !ok { @@ -53,7 +53,7 @@ func UpdateVariable(ctx *context.Context, redirectURL string) { } func DeleteVariable(ctx *context.Context, redirectURL string) { - id := ctx.ParamsInt64(":variable_id") + id := ctx.PathParamInt64(":variable_id") if err := actions_service.DeleteVariableByID(ctx, id); err != nil { log.Error("Delete variable [%d] failed: %v", id, err) diff --git a/routers/web/shared/packages/packages.go b/routers/web/shared/packages/packages.go index 57671ad8f14bc..1d3cabf71b4ec 100644 --- a/routers/web/shared/packages/packages.go +++ b/routers/web/shared/packages/packages.go @@ -204,7 +204,7 @@ func SetRulePreviewContext(ctx *context.Context, owner *user_model.User) { func getCleanupRuleByContext(ctx *context.Context, owner *user_model.User) *packages_model.PackageCleanupRule { id := ctx.FormInt64("id") if id == 0 { - id = ctx.ParamsInt64("id") + id = ctx.PathParamInt64("id") } pcr, err := packages_model.GetCleanupRuleByID(ctx, id) diff --git a/routers/web/shared/project/column.go b/routers/web/shared/project/column.go index 599842ea9e9bc..ba1f527beaafe 100644 --- a/routers/web/shared/project/column.go +++ b/routers/web/shared/project/column.go @@ -11,7 +11,7 @@ import ( // MoveColumns moves or keeps columns in a project and sorts them inside that project func MoveColumns(ctx *context.Context) { - project, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id")) + project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64(":id")) if err != nil { ctx.NotFoundOrServerError("GetProjectByID", project_model.IsErrProjectNotExist, err) return diff --git a/routers/web/user/avatar.go b/routers/web/user/avatar.go index 04f510161db62..7000e2577857b 100644 --- a/routers/web/user/avatar.go +++ b/routers/web/user/avatar.go @@ -23,8 +23,8 @@ func cacheableRedirect(ctx *context.Context, location string) { // AvatarByUserName redirect browser to user avatar of requested size func AvatarByUserName(ctx *context.Context) { - userName := ctx.Params(":username") - size := int(ctx.ParamsInt64(":size")) + userName := ctx.PathParam(":username") + size := int(ctx.PathParamInt64(":size")) var user *user_model.User if strings.ToLower(userName) != user_model.GhostUserLowerName { @@ -46,7 +46,7 @@ func AvatarByUserName(ctx *context.Context) { // AvatarByEmailHash redirects the browser to the email avatar link func AvatarByEmailHash(ctx *context.Context) { - hash := ctx.Params(":hash") + hash := ctx.PathParam(":hash") email, err := avatars.GetEmailForHash(ctx, hash) if err != nil { ctx.ServerError("invalid avatar hash: "+hash, err) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index b03a51403048a..e94433b3c5898 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -50,7 +50,7 @@ const ( // getDashboardContextUser finds out which context user dashboard is being viewed as . func getDashboardContextUser(ctx *context.Context) *user_model.User { ctxUser := ctx.Doer - orgName := ctx.Params(":org") + orgName := ctx.PathParam(":org") if len(orgName) > 0 { ctxUser = ctx.Org.Organization.AsUser() ctx.Data["Teams"] = ctx.Org.Teams @@ -714,9 +714,9 @@ func ShowGPGKeys(ctx *context.Context) { func UsernameSubRoute(ctx *context.Context) { // WORKAROUND to support usernames with "." in it // https://github.com/go-chi/chi/issues/781 - username := ctx.Params("username") + username := ctx.PathParam("username") reloadParam := func(suffix string) (success bool) { - ctx.SetParams("username", strings.TrimSuffix(username, suffix)) + ctx.SetPathParam("username", strings.TrimSuffix(username, suffix)) context.UserAssignmentWeb()(ctx) if ctx.Written() { return false diff --git a/routers/web/user/home_test.go b/routers/web/user/home_test.go index 1cc9886308c35..51246551ea2d8 100644 --- a/routers/web/user/home_test.go +++ b/routers/web/user/home_test.go @@ -83,7 +83,7 @@ func TestMilestones(t *testing.T) { ctx, _ := contexttest.MockContext(t, "milestones") contexttest.LoadUser(t, ctx, 2) - ctx.SetParams("sort", "issues") + ctx.SetPathParam("sort", "issues") ctx.Req.Form.Set("state", "closed") ctx.Req.Form.Set("sort", "furthestduedate") Milestones(ctx) @@ -102,8 +102,8 @@ func TestMilestonesForSpecificRepo(t *testing.T) { ctx, _ := contexttest.MockContext(t, "milestones") contexttest.LoadUser(t, ctx, 2) - ctx.SetParams("sort", "issues") - ctx.SetParams("repo", "1") + ctx.SetPathParam("sort", "issues") + ctx.SetPathParam("repo", "1") ctx.Req.Form.Set("state", "closed") ctx.Req.Form.Set("sort", "furthestduedate") Milestones(ctx) diff --git a/routers/web/user/package.go b/routers/web/user/package.go index dad4c8f602a57..4e39eabc0ffde 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -136,7 +136,7 @@ func ListPackages(ctx *context.Context) { // RedirectToLastVersion redirects to the latest package version func RedirectToLastVersion(ctx *context.Context) { - p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.Params("type")), ctx.Params("name")) + p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.PathParam("type")), ctx.PathParam("name")) if err != nil { if err == packages_model.ErrPackageNotExist { ctx.NotFound("GetPackageByName", err) @@ -298,7 +298,7 @@ func ViewPackageVersion(ctx *context.Context) { // ListPackageVersions lists all versions of a package func ListPackageVersions(ctx *context.Context) { shared_user.PrepareContextForProfileBigAvatar(ctx) - p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.Params("type")), ctx.Params("name")) + p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.PathParam("type")), ctx.PathParam("name")) if err != nil { if err == packages_model.ErrPackageNotExist { ctx.NotFound("GetPackageByName", err) @@ -485,7 +485,7 @@ func PackageSettingsPost(ctx *context.Context) { // DownloadPackageFile serves the content of a package file func DownloadPackageFile(ctx *context.Context) { - pf, err := packages_model.GetFileForVersionByID(ctx, ctx.Package.Descriptor.Version.ID, ctx.ParamsInt64(":fileid")) + pf, err := packages_model.GetFileForVersionByID(ctx, ctx.Package.Descriptor.Version.ID, ctx.PathParamInt64(":fileid")) if err != nil { if err == packages_model.ErrPackageFileNotExist { ctx.NotFound("", err) diff --git a/routers/web/user/setting/oauth2_common.go b/routers/web/user/setting/oauth2_common.go index 85d1e820a5144..4477dc570f80b 100644 --- a/routers/web/user/setting/oauth2_common.go +++ b/routers/web/user/setting/oauth2_common.go @@ -73,7 +73,7 @@ func (oa *OAuth2CommonHandlers) AddApp(ctx *context.Context) { // EditShow displays the given application func (oa *OAuth2CommonHandlers) EditShow(ctx *context.Context) { - app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id")) + app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.PathParamInt64("id")) if err != nil { if auth.IsErrOAuthApplicationNotFound(err) { ctx.NotFound("Application not found", err) @@ -102,7 +102,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) { // TODO validate redirect URI var err error if ctx.Data["App"], err = auth.UpdateOAuth2Application(ctx, auth.UpdateOAuth2ApplicationOptions{ - ID: ctx.ParamsInt64("id"), + ID: ctx.PathParamInt64("id"), Name: form.Name, RedirectURIs: util.SplitTrimSpace(form.RedirectURIs, "\n"), UserID: oa.OwnerID, @@ -117,7 +117,7 @@ func (oa *OAuth2CommonHandlers) EditSave(ctx *context.Context) { // RegenerateSecret regenerates the secret func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) { - app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.ParamsInt64("id")) + app, err := auth.GetOAuth2ApplicationByID(ctx, ctx.PathParamInt64("id")) if err != nil { if auth.IsErrOAuthApplicationNotFound(err) { ctx.NotFound("Application not found", err) @@ -142,7 +142,7 @@ func (oa *OAuth2CommonHandlers) RegenerateSecret(ctx *context.Context) { // DeleteApp deletes the given oauth2 application func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) { - if err := auth.DeleteOAuth2Application(ctx, ctx.ParamsInt64("id"), oa.OwnerID); err != nil { + if err := auth.DeleteOAuth2Application(ctx, ctx.PathParamInt64("id"), oa.OwnerID); err != nil { ctx.ServerError("DeleteOAuth2Application", err) return } @@ -153,7 +153,7 @@ func (oa *OAuth2CommonHandlers) DeleteApp(ctx *context.Context) { // RevokeGrant revokes the grant func (oa *OAuth2CommonHandlers) RevokeGrant(ctx *context.Context) { - if err := auth.RevokeOAuth2Grant(ctx, ctx.ParamsInt64("grantId"), oa.OwnerID); err != nil { + if err := auth.RevokeOAuth2Grant(ctx, ctx.PathParamInt64("grantId"), oa.OwnerID); err != nil { ctx.ServerError("RevokeOAuth2Grant", err) return } diff --git a/routers/web/user/task.go b/routers/web/user/task.go index 8476767e9e025..475ef16212f0b 100644 --- a/routers/web/user/task.go +++ b/routers/web/user/task.go @@ -14,11 +14,11 @@ import ( // TaskStatus returns task's status func TaskStatus(ctx *context.Context) { - task, opts, err := admin_model.GetMigratingTaskByID(ctx, ctx.ParamsInt64("task"), ctx.Doer.ID) + task, opts, err := admin_model.GetMigratingTaskByID(ctx, ctx.PathParamInt64("task"), ctx.Doer.ID) if err != nil { if admin_model.IsErrTaskDoesNotExist(err) { ctx.JSON(http.StatusNotFound, map[string]any{ - "error": "task `" + strconv.FormatInt(ctx.ParamsInt64("task"), 10) + "` does not exist", + "error": "task `" + strconv.FormatInt(ctx.PathParamInt64("task"), 10) + "` does not exist", }) return } diff --git a/routers/web/web.go b/routers/web/web.go index 08f5d3d068a14..9f9a1bb0988e6 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -226,8 +226,8 @@ func ctxDataSet(args ...any) func(ctx *context.Context) { } // Routes returns all web routes -func Routes() *web.Route { - routes := web.NewRoute() +func Routes() *web.Router { + routes := web.NewRouter() routes.Head("/", misc.DummyOK) // for health check - doesn't need to be passed through gzip handler routes.Methods("GET, HEAD, OPTIONS", "/assets/*", optionsCorsHandler(), public.FileHandlerFunc()) @@ -283,7 +283,7 @@ func Routes() *web.Route { mid = append(mid, repo.GetActiveStopwatch) mid = append(mid, goGet) - others := web.NewRoute() + others := web.NewRouter() others.Use(mid...) registerRoutes(others) routes.Mount("", others) @@ -293,7 +293,7 @@ func Routes() *web.Route { var ignSignInAndCsrf = verifyAuthWithOptions(&common.VerifyOptions{DisableCSRF: true}) // registerRoutes register routes -func registerRoutes(m *web.Route) { +func registerRoutes(m *web.Router) { reqSignIn := verifyAuthWithOptions(&common.VerifyOptions{SignInRequired: true}) reqSignOut := verifyAuthWithOptions(&common.VerifyOptions{SignOutRequired: true}) // TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView) @@ -384,18 +384,18 @@ func registerRoutes(m *web.Route) { return func(ctx *context.Context) { // only check global disabled units when ignoreGlobal is false if !ignoreGlobal && unitType.UnitGlobalDisabled() { - ctx.NotFound(unitType.String(), nil) + ctx.NotFound("Repo unit is is disabled: "+unitType.LogString(), nil) return } if ctx.ContextUser == nil { - ctx.NotFound(unitType.String(), nil) + ctx.NotFound("ContextUser is nil", nil) return } if ctx.ContextUser.IsOrganization() { if ctx.Org.Organization.UnitPermission(ctx, ctx.Doer, unitType) < accessMode { - ctx.NotFound(unitType.String(), nil) + ctx.NotFound("ContextUser is org but doer has no access to unit", nil) return } } @@ -487,7 +487,7 @@ func registerRoutes(m *web.Route) { m.Get("/organizations", explore.Organizations) m.Get("/code", func(ctx *context.Context) { if unit.TypeCode.UnitGlobalDisabled() { - ctx.NotFound(unit.TypeCode.String(), nil) + ctx.NotFound("Repo unit code is disabled", nil) return } }, explore.Code) diff --git a/services/context/api.go b/services/context/api.go index c684add297d13..84da526e748f8 100644 --- a/services/context/api.go +++ b/services/context/api.go @@ -317,7 +317,7 @@ func RepoRefForAPI(next http.Handler) http.Handler { } ctx.Repo.Commit = commit ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() - ctx.Repo.TreePath = ctx.Params("*") + ctx.Repo.TreePath = ctx.PathParam("*") next.ServeHTTP(w, req) return } @@ -347,7 +347,7 @@ func RepoRefForAPI(next http.Handler) http.Handler { return } } else { - ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.Params("*"))) + ctx.NotFound(fmt.Errorf("not exist: '%s'", ctx.PathParam("*"))) return } diff --git a/services/context/base.go b/services/context/base.go index 23f0bcfc33ba6..68619bf067800 100644 --- a/services/context/base.go +++ b/services/context/base.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/optional" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/translation" "code.gitea.io/gitea/modules/web/middleware" @@ -142,24 +143,28 @@ func (b *Base) RemoteAddr() string { return b.Req.RemoteAddr } -// Params returns the param on route -func (b *Base) Params(p string) string { - s, _ := url.PathUnescape(chi.URLParam(b.Req, strings.TrimPrefix(p, ":"))) +// PathParam returns the param in request path, eg: "/{var}" => "/a%2fb", then `var == "a/b"` +func (b *Base) PathParam(name string) string { + s, err := url.PathUnescape(b.PathParamRaw(name)) + if err != nil && !setting.IsProd { + panic("Failed to unescape path param: " + err.Error() + ", there seems to be a double-unescaping bug") + } return s } -func (b *Base) PathParamRaw(p string) string { - return chi.URLParam(b.Req, strings.TrimPrefix(p, ":")) +// PathParamRaw returns the raw param in request path, eg: "/{var}" => "/a%2fb", then `var == "a%2fb"` +func (b *Base) PathParamRaw(name string) string { + return chi.URLParam(b.Req, strings.TrimPrefix(name, ":")) } -// ParamsInt64 returns the param on route as int64 -func (b *Base) ParamsInt64(p string) int64 { - v, _ := strconv.ParseInt(b.Params(p), 10, 64) +// PathParamInt64 returns the param in request path as int64 +func (b *Base) PathParamInt64(p string) int64 { + v, _ := strconv.ParseInt(b.PathParam(p), 10, 64) return v } -// SetParams set params into routes -func (b *Base) SetParams(k, v string) { +// SetPathParam set request path params into routes +func (b *Base) SetPathParam(k, v string) { chiCtx := chi.RouteContext(b) chiCtx.URLParams.Add(strings.TrimPrefix(k, ":"), url.PathEscape(v)) } diff --git a/services/context/context.go b/services/context/context.go index aab0485f1a494..69b65cbddbc92 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -210,16 +210,9 @@ func Contexter() func(next http.Handler) http.Handler { // FIXME: do we really always need these setting? There should be someway to have to avoid having to always set these ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations ctx.Data["DisableStars"] = setting.Repository.DisableStars - ctx.Data["EnableActions"] = setting.Actions.Enabled + ctx.Data["EnableActions"] = setting.Actions.Enabled && !unit.TypeActions.UnitGlobalDisabled() ctx.Data["ManifestData"] = setting.ManifestData - - ctx.Data["UnitWikiGlobalDisabled"] = unit.TypeWiki.UnitGlobalDisabled() - ctx.Data["UnitIssuesGlobalDisabled"] = unit.TypeIssues.UnitGlobalDisabled() - ctx.Data["UnitPullsGlobalDisabled"] = unit.TypePullRequests.UnitGlobalDisabled() - ctx.Data["UnitProjectsGlobalDisabled"] = unit.TypeProjects.UnitGlobalDisabled() - ctx.Data["UnitActionsGlobalDisabled"] = unit.TypeActions.UnitGlobalDisabled() - ctx.Data["AllLangs"] = translation.AllLangs() next.ServeHTTP(ctx.Resp, ctx.Req) diff --git a/services/context/org.go b/services/context/org.go index 018b76de43a03..7eba80ff96b1f 100644 --- a/services/context/org.go +++ b/services/context/org.go @@ -41,7 +41,7 @@ func (org *Organization) CanReadUnit(ctx *Context, unitType unit.Type) bool { } func GetOrganizationByParams(ctx *Context) { - orgName := ctx.Params(":org") + orgName := ctx.PathParam(":org") var err error @@ -221,7 +221,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Data["NumTeams"] = len(ctx.Org.Teams) } - teamName := ctx.Params(":team") + teamName := ctx.PathParam(":team") if len(teamName) > 0 { teamExists := false for _, team := range ctx.Org.Teams { diff --git a/services/context/package.go b/services/context/package.go index c452c657e782c..271b61e99c323 100644 --- a/services/context/package.go +++ b/services/context/package.go @@ -68,9 +68,9 @@ func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, any)) return pkg } - packageType := ctx.Params("type") - name := ctx.Params("name") - version := ctx.Params("version") + packageType := ctx.PathParam("type") + name := ctx.PathParam("name") + version := ctx.PathParam("version") if packageType != "" && name != "" && version != "" { pv, err := packages_model.GetVersionByNameAndVersion(ctx, pkg.Owner.ID, packages_model.Type(packageType), name, version) if err != nil { diff --git a/services/context/repo.go b/services/context/repo.go index d9a3feaf272e4..e0d3a0bfd3e43 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -319,8 +319,8 @@ func ComposeGoGetImport(owner, repo string) string { // This is particular a workaround for "go get" command which does not respect // .netrc file. func EarlyResponseForGoGetMeta(ctx *Context) { - username := ctx.Params(":username") - reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") + username := ctx.PathParam(":username") + reponame := strings.TrimSuffix(ctx.PathParam(":reponame"), ".git") if username == "" || reponame == "" { ctx.PlainText(http.StatusBadRequest, "invalid repository path") return @@ -339,8 +339,8 @@ func EarlyResponseForGoGetMeta(ctx *Context) { // RedirectToRepo redirect to a differently-named repository func RedirectToRepo(ctx *Base, redirectRepoID int64) { - ownerName := ctx.Params(":username") - previousRepoName := ctx.Params(":reponame") + ownerName := ctx.PathParam(":username") + previousRepoName := ctx.PathParam(":reponame") repo, err := repo_model.GetRepositoryByID(ctx, redirectRepoID) if err != nil { @@ -419,8 +419,8 @@ func RepoAssignment(ctx *Context) context.CancelFunc { err error ) - userName := ctx.Params(":username") - repoName := ctx.Params(":reponame") + userName := ctx.PathParam(":username") + repoName := ctx.PathParam(":reponame") repoName = strings.TrimSuffix(repoName, ".git") if setting.Other.EnableFeed { repoName = strings.TrimSuffix(repoName, ".rss") @@ -463,7 +463,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc { if strings.HasSuffix(repoName, ".wiki") { // ctx.Req.URL.Path does not have the preceding appSubURL - any redirect must have this added // Now we happen to know that all of our paths are: /:username/:reponame/whatever_else - originalRepoName := ctx.Params(":reponame") + originalRepoName := ctx.PathParam(":reponame") redirectRepoName := strings.TrimSuffix(repoName, ".wiki") redirectRepoName += originalRepoName[len(redirectRepoName)+5:] redirectPath := strings.Replace( @@ -801,7 +801,7 @@ func getRefNameFromPath(repo *Repository, path string, isExist func(string) bool } func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string { - path := ctx.Params("*") + path := ctx.PathParam("*") switch pathType { case RepoRefLegacy, RepoRefAny: if refName := getRefName(ctx, repo, RepoRefBranch); len(refName) > 0 { @@ -917,7 +917,7 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context } // Get default branch. - if len(ctx.Params("*")) == 0 { + if len(ctx.PathParam("*")) == 0 { refName = ctx.Repo.Repository.DefaultBranch if !ctx.Repo.GitRepo.IsBranchExist(refName) { brs, _, err := ctx.Repo.GitRepo.GetBranches(0, 1) @@ -1005,13 +1005,13 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context if refType == RepoRefLegacy { // redirect from old URL scheme to new URL scheme - prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.Params("*"))), strings.ToLower(ctx.Repo.RepoLink)) - - ctx.Redirect(path.Join( + prefix := strings.TrimPrefix(setting.AppSubURL+strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ctx.PathParam("*"))), strings.ToLower(ctx.Repo.RepoLink)) + redirect := path.Join( ctx.Repo.RepoLink, util.PathEscapeSegments(prefix), ctx.Repo.BranchNameSubURL(), - util.PathEscapeSegments(ctx.Repo.TreePath))) + util.PathEscapeSegments(ctx.Repo.TreePath)) + ctx.Redirect(redirect) return cancel } } diff --git a/services/context/upload/upload.go b/services/context/upload/upload.go index 77a7eb9377362..7123420e99284 100644 --- a/services/context/upload/upload.go +++ b/services/context/upload/upload.go @@ -86,8 +86,8 @@ func AddUploadContext(ctx *context.Context, uploadType string) { } else if uploadType == "comment" { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove" - if len(ctx.Params(":index")) > 0 { - ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.Params(":index")) + "/attachments" + if len(ctx.PathParam(":index")) > 0 { + ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + url.PathEscape(ctx.PathParam(":index")) + "/attachments" } else { ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/attachments" } diff --git a/services/context/user.go b/services/context/user.go index 4c9cd2928b94d..b0e855e923185 100644 --- a/services/context/user.go +++ b/services/context/user.go @@ -33,7 +33,7 @@ func UserAssignmentWeb() func(ctx *Context) { // UserIDAssignmentAPI returns a middleware to handle context-user assignment for api routes func UserIDAssignmentAPI() func(ctx *APIContext) { return func(ctx *APIContext) { - userID := ctx.ParamsInt64(":user-id") + userID := ctx.PathParamInt64(":user-id") if ctx.IsSigned && ctx.Doer.ID == userID { ctx.ContextUser = ctx.Doer @@ -59,7 +59,7 @@ func UserAssignmentAPI() func(ctx *APIContext) { } func userAssignment(ctx *Base, doer *user_model.User, errCb func(int, string, any)) (contextUser *user_model.User) { - username := ctx.Params(":username") + username := ctx.PathParam(":username") if doer != nil && doer.LowerName == strings.ToLower(username) { contextUser = doer diff --git a/services/externalaccount/user.go b/services/externalaccount/user.go index e2de41da188e5..3cfd8c81f9fc7 100644 --- a/services/externalaccount/user.go +++ b/services/externalaccount/user.go @@ -5,6 +5,7 @@ package externalaccount import ( "context" + "strconv" "strings" "code.gitea.io/gitea/models/auth" @@ -82,6 +83,11 @@ func UpdateExternalUser(ctx context.Context, user *user_model.User, gothUser got // UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID func UpdateMigrationsByType(ctx context.Context, tp structs.GitServiceType, externalUserID string, userID int64) error { + // Skip update if externalUserID is not a valid numeric ID or exceeds int64 + if _, err := strconv.ParseInt(externalUserID, 10, 64); err != nil { + return nil + } + if err := issues_model.UpdateIssuesMigrationsByType(ctx, tp, externalUserID, userID); err != nil { return err } diff --git a/services/lfs/locks.go b/services/lfs/locks.go index 2a362b1c0d4c7..4254c99383fa1 100644 --- a/services/lfs/locks.go +++ b/services/lfs/locks.go @@ -136,8 +136,8 @@ func GetListLockHandler(ctx *context.Context) { // PostLockHandler create lock func PostLockHandler(ctx *context.Context) { - userName := ctx.Params("username") - repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git") + userName := ctx.PathParam("username") + repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git") authorization := ctx.Req.Header.Get("Authorization") repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName) @@ -208,8 +208,8 @@ func PostLockHandler(ctx *context.Context) { // VerifyLockHandler list locks for verification func VerifyLockHandler(ctx *context.Context) { - userName := ctx.Params("username") - repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git") + userName := ctx.PathParam("username") + repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git") authorization := ctx.Req.Header.Get("Authorization") repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName) @@ -279,8 +279,8 @@ func VerifyLockHandler(ctx *context.Context) { // UnLockHandler delete locks func UnLockHandler(ctx *context.Context) { - userName := ctx.Params("username") - repoName := strings.TrimSuffix(ctx.Params("reponame"), ".git") + userName := ctx.PathParam("username") + repoName := strings.TrimSuffix(ctx.PathParam("reponame"), ".git") authorization := ctx.Req.Header.Get("Authorization") repository, err := repo_model.GetRepositoryByOwnerAndName(ctx, userName, repoName) @@ -321,7 +321,7 @@ func UnLockHandler(ctx *context.Context) { return } - lock, err := git_model.DeleteLFSLockByID(ctx, ctx.ParamsInt64("lid"), repository, ctx.Doer, req.Force) + lock, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), repository, ctx.Doer, req.Force) if err != nil { if git_model.IsErrLFSUnauthorizedAction(err) { ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=gitea-lfs") @@ -330,7 +330,7 @@ func UnLockHandler(ctx *context.Context) { }) return } - log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.ParamsInt64("lid"), ctx.Doer, req.Force, err) + log.Error("Unable to DeleteLFSLockByID[%d] by user %-v with force %t: Error: %v", ctx.PathParamInt64("lid"), ctx.Doer, req.Force, err) ctx.JSON(http.StatusInternalServerError, api.LFSLockError{ Message: "unable to delete lock : Internal Server Error", }) diff --git a/services/lfs/server.go b/services/lfs/server.go index ae3dffe0c2912..751dac64a02f9 100644 --- a/services/lfs/server.go +++ b/services/lfs/server.go @@ -82,7 +82,7 @@ var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`) // DownloadHandler gets the content from the content store func DownloadHandler(ctx *context.Context) { rc := getRequestContext(ctx) - p := lfs_module.Pointer{Oid: ctx.Params("oid")} + p := lfs_module.Pointer{Oid: ctx.PathParam("oid")} meta := getAuthenticatedMeta(ctx, rc, p, false) if meta == nil { @@ -137,7 +137,7 @@ func DownloadHandler(ctx *context.Context) { ctx.Resp.Header().Set("Content-Length", strconv.FormatInt(contentLength, 10)) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") - filename := ctx.Params("filename") + filename := ctx.PathParam("filename") if len(filename) > 0 { decodedFilename, err := base64.RawURLEncoding.DecodeString(filename) if err == nil { @@ -272,9 +272,9 @@ func BatchHandler(ctx *context.Context) { func UploadHandler(ctx *context.Context) { rc := getRequestContext(ctx) - p := lfs_module.Pointer{Oid: ctx.Params("oid")} + p := lfs_module.Pointer{Oid: ctx.PathParam("oid")} var err error - if p.Size, err = strconv.ParseInt(ctx.Params("size"), 10, 64); err != nil { + if p.Size, err = strconv.ParseInt(ctx.PathParam("size"), 10, 64); err != nil { writeStatusMessage(ctx, http.StatusUnprocessableEntity, err.Error()) } @@ -384,8 +384,8 @@ func decodeJSON(req *http.Request, v any) error { func getRequestContext(ctx *context.Context) *requestContext { return &requestContext{ - User: ctx.Params("username"), - Repo: strings.TrimSuffix(ctx.Params("reponame"), ".git"), + User: ctx.PathParam("username"), + Repo: strings.TrimSuffix(ctx.PathParam("reponame"), ".git"), Authorization: ctx.Req.Header.Get("Authorization"), } } diff --git a/services/repository/files/content_test.go b/services/repository/files/content_test.go index 4811f9d327a13..a899be70e3386 100644 --- a/services/repository/files/content_test.go +++ b/services/repository/files/content_test.go @@ -53,7 +53,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse { func TestGetContents(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -81,7 +81,7 @@ func TestGetContents(t *testing.T) { func TestGetContentsOrListForDir(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -116,7 +116,7 @@ func TestGetContentsOrListForDir(t *testing.T) { func TestGetContentsOrListForFile(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -144,7 +144,7 @@ func TestGetContentsOrListForFile(t *testing.T) { func TestGetContentsErrors(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -175,7 +175,7 @@ func TestGetContentsErrors(t *testing.T) { func TestGetContentsOrListErrors(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -206,7 +206,7 @@ func TestGetContentsOrListErrors(t *testing.T) { func TestGetContentsOrListOfEmptyRepos(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user30/empty") - ctx.SetParams(":id", "52") + ctx.SetPathParam(":id", "52") contexttest.LoadRepo(t, ctx, 52) contexttest.LoadUser(t, ctx, 30) contexttest.LoadGitRepo(t, ctx) @@ -231,15 +231,15 @@ func TestGetBlobBySHA(t *testing.T) { defer ctx.Repo.GitRepo.Close() sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d" - ctx.SetParams(":id", "1") - ctx.SetParams(":sha", sha) + ctx.SetPathParam(":id", "1") + ctx.SetPathParam(":sha", sha) gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { t.Fail() } - gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.Params(":sha")) + gbr, err := GetBlobBySHA(ctx, ctx.Repo.Repository, gitRepo, ctx.PathParam(":sha")) expectedGBR := &api.GitBlobResponse{ Content: "dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK", Encoding: "base64", diff --git a/services/repository/files/diff_test.go b/services/repository/files/diff_test.go index 63aff9b0e3099..ea6ffe60c3f88 100644 --- a/services/repository/files/diff_test.go +++ b/services/repository/files/diff_test.go @@ -18,7 +18,7 @@ import ( func TestGetDiffPreview(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) @@ -140,7 +140,7 @@ func TestGetDiffPreview(t *testing.T) { func TestGetDiffPreviewErrors(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) diff --git a/services/repository/files/file_test.go b/services/repository/files/file_test.go index a5b3aad91e32b..b2f51e3c820f7 100644 --- a/services/repository/files/file_test.go +++ b/services/repository/files/file_test.go @@ -99,7 +99,7 @@ func getExpectedFileResponse() *api.FileResponse { func TestGetFileResponseFromCommit(t *testing.T) { unittest.PrepareTestEnv(t) ctx, _ := contexttest.MockContext(t, "user2/repo1") - ctx.SetParams(":id", "1") + ctx.SetPathParam(":id", "1") contexttest.LoadRepo(t, ctx, 1) contexttest.LoadRepoCommit(t, ctx) contexttest.LoadUser(t, ctx, 2) diff --git a/services/repository/files/tree_test.go b/services/repository/files/tree_test.go index 508f20090ddc6..786bc15857c48 100644 --- a/services/repository/files/tree_test.go +++ b/services/repository/files/tree_test.go @@ -25,10 +25,10 @@ func TestGetTreeBySHA(t *testing.T) { sha := ctx.Repo.Repository.DefaultBranch page := 1 perPage := 10 - ctx.SetParams(":id", "1") - ctx.SetParams(":sha", sha) + ctx.SetPathParam(":id", "1") + ctx.SetPathParam(":sha", sha) - tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Params(":sha"), page, perPage, true) + tree, err := GetTreeBySHA(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.PathParam(":sha"), page, perPage, true) assert.NoError(t, err) expectedTree := &api.GitTreeResponse{ SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d", diff --git a/services/wiki/wiki_path.go b/services/wiki/wiki_path.go index 74c706404368e..212a35ea2551e 100644 --- a/services/wiki/wiki_path.go +++ b/services/wiki/wiki_path.go @@ -33,7 +33,7 @@ import ( // TODO: support subdirectory in the future // // Although this package now has the ability to support subdirectory, but the route package doesn't: -// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.Params, which is incorrect +// * Double-escaping problem: the URL "/wiki/abc%2Fdef" becomes "/wiki/abc/def" by ctx.PathParam, which is incorrect // * This problem should have been 99% fixed, but it needs more tests. // * The old wiki code's behavior is always using %2F, instead of subdirectory, so there are a lot of legacy "%2F" files in user wikis. diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 4889924819360..7be2d96d74400 100644 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -35,13 +35,13 @@ {{if and .IsSigned .MustChangePassword}} {{/* No links */}} {{else if .IsSigned}} - {{if not .UnitIssuesGlobalDisabled}} + {{if not ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled}} {{ctx.Locale.Tr "issues"}} {{end}} - {{if not .UnitPullsGlobalDisabled}} + {{if not ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled}} {{ctx.Locale.Tr "pull_requests"}} {{end}} - {{if not (and .UnitIssuesGlobalDisabled .UnitPullsGlobalDisabled)}} + {{if not (and ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled)}} {{if .ShowMilestonesDashboardPage}} {{ctx.Locale.Tr "milestones"}} {{end}} diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl index 3e7cd92066264..62d1bbf2ba7c4 100644 --- a/templates/repo/blame.tmpl +++ b/templates/repo/blame.tmpl @@ -2,7 +2,7 @@ {{$revsFileLink := URLJoin .RepoLink "src" .BranchNameSubURL "/.git-blame-ignore-revs"}} {{if .UsesIgnoreRevs}}
-

{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink (print $revsFileLink "?bypass-blame-ignore=true")}}

+

{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink "?bypass-blame-ignore=true"}}

{{else}}
diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl index 2874ac6a55c61..cc2237029bd68 100644 --- a/templates/repo/diff/blob_excerpt.tmpl +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -53,17 +53,17 @@
{{if or (eq $expandDirection 3) (eq $expandDirection 5)}} - {{end}} {{if or (eq $expandDirection 3) (eq $expandDirection 4)}} - {{end}} {{if eq $expandDirection 2}} - {{end}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 22daaab4bc1ba..d52891b02a76a 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -162,7 +162,7 @@ {{end}} - {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}} + {{if and .EnableActions (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}} {{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}} {{if .Repository.NumOpenActionRuns}} @@ -178,7 +178,7 @@ {{end}} {{$projectsUnit := .Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeProjects}} - {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}} + {{if and (not ctx.Consts.RepoUnitTypeProjects.UnitGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}} {{svg "octicon-project"}} {{ctx.Locale.Tr "repo.projects"}} {{if .Repository.NumOpenProjects}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 3da2f3815ee3f..d8ca9de7bde0d 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -574,7 +574,6 @@ {{template "repo/commits_list_small" dict "comment" . "root" $}} {{end}} {{else if eq .Type 30}} - {{if not $.UnitProjectsGlobalDisabled}}
{{svg "octicon-project"}} {{template "shared/user/avatarlink" dict "user" .Poster}} @@ -599,7 +598,6 @@ {{end}}
- {{end}} {{else if eq .Type 32}}
diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl index 17556d4e4894a..9e38442c369fd 100644 --- a/templates/repo/issue/view_content/context_menu.tmpl +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -15,7 +15,7 @@ {{if not .ctxData.Repository.IsArchived}} {{$needDivider = true}}
{{ctx.Locale.Tr "repo.issues.context.quote_reply"}}
- {{if not .ctxData.UnitIssuesGlobalDisabled}} + {{if not ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled}}
{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}
{{end}} {{if or .ctxData.Permission.IsAdmin .IsCommentPoster .ctxData.HasIssuesOrPullsWritePermission}} diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index 414effbf2f3bd..b9105bb8ed8a4 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -35,7 +35,7 @@
{{end}} {{end}} - {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}} + {{if and .EnableActions (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
{{ctx.Locale.Tr "actions.actions"}}