diff options
author | silverwind <me@silverwind.io> | 2020-06-20 16:23:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-20 15:23:04 +0100 |
commit | dcbbf37082898dbca8bc3e5f1e3003c56955a675 (patch) | |
tree | d6be0ebabb0b57ea727f07204e96be93a95b32b0 | |
parent | 3e8618a543cc942e5de4d4728b0f107b18b998ff (diff) | |
download | gitea-dcbbf37082898dbca8bc3e5f1e3003c56955a675.tar.gz gitea-dcbbf37082898dbca8bc3e5f1e3003c56955a675.zip |
Add serviceworker.js to KnownPublicEntries (#11992) (#11994)
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.
-rw-r--r-- | models/user.go | 11 | ||||
-rw-r--r-- | modules/public/public.go | 7 |
2 files changed, 8 insertions, 10 deletions
diff --git a/models/user.go b/models/user.go index 1c1332d532..680c302313 100644 --- a/models/user.go +++ b/models/user.go @@ -29,6 +29,7 @@ import ( "code.gitea.io/gitea/modules/generate" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/public" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs" @@ -878,7 +879,7 @@ func (u *User) IsGhost() bool { } var ( - reservedUsernames = []string{ + reservedUsernames = append([]string{ ".", "..", ".well-known", @@ -888,17 +889,13 @@ var ( "attachments", "avatars", "commits", - "css", "debug", "error", "explore", - "fomantic", "ghost", "help", - "img", "install", "issues", - "js", "less", "login", "manifest.json", @@ -916,8 +913,8 @@ var ( "stars", "template", "user", - "vendor", - } + }, public.KnownPublicEntries...) + reservedUserPatterns = []string{"*.keys", "*.gpg"} ) diff --git a/modules/public/public.go b/modules/public/public.go index fb8d9c1955..8d027855c2 100644 --- a/modules/public/public.go +++ b/modules/public/public.go @@ -30,12 +30,13 @@ type Options struct { Prefix string } -// List of known entries inside the `public` directory -var knownEntries = []string{ +// KnownPublicEntries list all direct children in the `public` directory +var KnownPublicEntries = []string{ "css", "fomantic", "img", "js", + "serviceworker.js", "vendor", } @@ -114,7 +115,7 @@ func (opts *Options) handle(ctx *macaron.Context, log *log.Logger, opt *Options) if len(parts) < 2 { return false } - for _, entry := range knownEntries { + for _, entry := range KnownPublicEntries { if entry == parts[1] { ctx.Resp.WriteHeader(404) return true |