mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-30 04:15:21 +00:00
Add serviceworker.js to KnownPublicEntries (#11992)
Fixes a wrong 302 redirect to the login page, see https://github.com/go-gitea/gitea/issues/11989. Also made it so the reserved username list is extended with those known entries so we avoid code duplication. Should be backported to 1.12.
This commit is contained in:
parent
6891b90303
commit
e24ee48776
|
@ -29,6 +29,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/generate"
|
"code.gitea.io/gitea/modules/generate"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/public"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/structs"
|
"code.gitea.io/gitea/modules/structs"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
@ -879,7 +880,7 @@ func (u *User) IsGhost() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reservedUsernames = []string{
|
reservedUsernames = append([]string{
|
||||||
".",
|
".",
|
||||||
"..",
|
"..",
|
||||||
".well-known",
|
".well-known",
|
||||||
|
@ -889,17 +890,13 @@ var (
|
||||||
"attachments",
|
"attachments",
|
||||||
"avatars",
|
"avatars",
|
||||||
"commits",
|
"commits",
|
||||||
"css",
|
|
||||||
"debug",
|
"debug",
|
||||||
"error",
|
"error",
|
||||||
"explore",
|
"explore",
|
||||||
"fomantic",
|
|
||||||
"ghost",
|
"ghost",
|
||||||
"help",
|
"help",
|
||||||
"img",
|
|
||||||
"install",
|
"install",
|
||||||
"issues",
|
"issues",
|
||||||
"js",
|
|
||||||
"less",
|
"less",
|
||||||
"login",
|
"login",
|
||||||
"manifest.json",
|
"manifest.json",
|
||||||
|
@ -917,8 +914,8 @@ var (
|
||||||
"stars",
|
"stars",
|
||||||
"template",
|
"template",
|
||||||
"user",
|
"user",
|
||||||
"vendor",
|
}, public.KnownPublicEntries...)
|
||||||
}
|
|
||||||
reservedUserPatterns = []string{"*.keys", "*.gpg"}
|
reservedUserPatterns = []string{"*.keys", "*.gpg"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,13 @@ type Options struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of known entries inside the `public` directory
|
// KnownPublicEntries list all direct children in the `public` directory
|
||||||
var knownEntries = []string{
|
var KnownPublicEntries = []string{
|
||||||
"css",
|
"css",
|
||||||
"fomantic",
|
"fomantic",
|
||||||
"img",
|
"img",
|
||||||
"js",
|
"js",
|
||||||
|
"serviceworker.js",
|
||||||
"vendor",
|
"vendor",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ func (opts *Options) handle(ctx *macaron.Context, log *log.Logger, opt *Options)
|
||||||
if len(parts) < 2 {
|
if len(parts) < 2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, entry := range knownEntries {
|
for _, entry := range KnownPublicEntries {
|
||||||
if entry == parts[1] {
|
if entry == parts[1] {
|
||||||
ctx.Resp.WriteHeader(404)
|
ctx.Resp.WriteHeader(404)
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue