Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Oct 10, 2024
1 parent c221767 commit c5b8ec4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 57 deletions.
56 changes: 29 additions & 27 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,41 +565,43 @@ var (
".",
"..",
".well-known",
"api",
"assets",
"attachments",
"avatar",
"avatars",

"api", // gitea api
"metrics", // prometheus metrics api
"v2", // container registry api

"assets", // static asset files
"attachments", // issue attachments

"avatar", // avatar by email hash
"avatars", // user avatars by file name
"repo-avatars",

"captcha",
"commits",
"debug",
"error",
"login", // oauth2 login
"org", // org create/manage, or "/org/{org}", BUT if an org is named as "invite" then it goes wrong
"repo", // repo create/migrate, etc
"user", // user login/activate/settings, etc

"explore",
"favicon.ico",
"ghost",
"issues",
"login",
"manifest.json",
"metrics",
"pulls",
"milestones",
"new",
"notifications",
"org",
"pulls",
"raw",
"repo",
"repo-avatars",
"robots.txt",
"search",
"serviceworker.js",
"ssh_info",

"favicon.ico",
"manifest.json", // web app manifests
"robots.txt", // search engine robots
"sitemap.xml", // search engine sitemap
"ssh_info", // agit info
"swagger.v1.json",
"user",
"v2",
"gitea-actions",

"ghost", // reserved name for deleted users (id: -1)
"gitea-actions", // gitea builtin user (id: -2)
}

// DON'T ADD ANY NEW STUFF, WE SOLVE THIS WITH `/user/{obj}` PATHS!
// These names are reserved for user accounts: user's keys, user's rss feed, user's avatar, etc.
// DO NOT add any new stuff! The paths with these names are processed by `/{username}` handler (UsernameSubRoute) manually.
reservedUserPatterns = []string{"*.keys", "*.gpg", "*.rss", "*.atom", "*.png"}
)

Expand Down
31 changes: 1 addition & 30 deletions tests/integration/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,7 @@ func TestRenameReservedUsername(t *testing.T) {
reservedUsernames := []string{
// ".", "..", ".well-known", // The names are not only reserved but also invalid
"api",
"assets",
"attachments",
"avatar",
"avatars",
"captcha",
"commits",
"debug",
"error",
"explore",
"favicon.ico",
"ghost",
"issues",
"login",
"manifest.json",
"metrics",
"milestones",
"new",
"notifications",
"org",
"pulls",
"raw",
"repo",
"repo-avatars",
"robots.txt",
"search",
"serviceworker.js",
"ssh_info",
"swagger.v1.json",
"user",
"v2",
"name.keys",
}

session := loginUser(t, "user2")
Expand Down

0 comments on commit c5b8ec4

Please sign in to comment.