-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Support "." char as user name for User/Orgs in RSS/ATOM/GPG/KEYS path ... #23874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
74fedb2
6a9e90c
df424ee
a85694f
a486a46
4ae6695
0129cb1
f515159
4cc8623
9d8cd97
96b1b30
1a78424
69cb014
6b5f2dc
808bacb
89ce389
8418d40
94c3ee3
2e974f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1220,3 +1220,41 @@ | |
| repo_admin_change_team_access: false | ||
| theme: "" | ||
| keep_activity_private: false | ||
|
|
||
| - | ||
| id: 34 | ||
| lower_name: the_34-user.with.all.allowedchars | ||
| name: the_34-user.with.all.allowedChars | ||
| full_name: the_1-user.with.all.allowedChars | ||
| description: 'some [commonmark](https://commonmark.org/)!' | ||
| email: [email protected] | ||
| keep_email_private: false | ||
| email_notifications_preference: enabled | ||
| passwd: ZogKvWdyEx:password | ||
| passwd_hash_algo: dummy | ||
| must_change_password: false | ||
| login_source: 0 | ||
| login_name: the_34-user.with.all.allowedchars | ||
| type: 0 | ||
| salt: ZogKvWdyEx | ||
| max_repo_creation: -1 | ||
| is_active: true | ||
| is_admin: false | ||
| is_restricted: false | ||
| allow_git_hook: false | ||
| allow_import_local: false | ||
| allow_create_organization: false | ||
| prohibit_login: false | ||
| avatar: avatar34 | ||
| avatar_email: [email protected] | ||
| use_custom_avatar: true | ||
| num_followers: 0 | ||
| num_following: 0 | ||
| num_stars: 0 | ||
| num_repos: 0 | ||
| num_teams: 0 | ||
| num_members: 0 | ||
| visibility: 0 | ||
| repo_admin_change_team_access: false | ||
| theme: "" | ||
| keep_activity_private: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "net/http" | ||
| "os" | ||
| "path" | ||
| "strings" | ||
|
|
||
| "code.gitea.io/gitea/models/perm" | ||
| "code.gitea.io/gitea/models/unit" | ||
|
|
@@ -535,6 +536,7 @@ func RegisterRoutes(m *web.Route) { | |
| m.Get("/activate", auth.Activate) | ||
| m.Post("/activate", auth.ActivatePost) | ||
| m.Any("/activate_email", auth.ActivateEmail) | ||
| m.Get("/avatar/{username}", user.AvatarByUserName) | ||
| m.Get("/avatar/{username}/{size}", user.AvatarByUserName) | ||
| m.Get("/recover_account", auth.ResetPasswd) | ||
| m.Post("/recover_account", auth.ResetPasswdPost) | ||
|
|
@@ -672,16 +674,43 @@ func RegisterRoutes(m *web.Route) { | |
| }) | ||
| http.ServeFile(ctx.Resp, ctx.Req, path.Join(setting.StaticRootPath, "public/img/favicon.png")) | ||
| }) | ||
| m.Group("/{username}", func() { | ||
| m.Get(".png", user.AvatarByUserName) | ||
| m.Get(".keys", user.ShowSSHKeys) | ||
| m.Get(".gpg", user.ShowGPGKeys) | ||
| m.Get(".rss", feedEnabled, feed.ShowUserFeedRSS) | ||
| m.Get(".atom", feedEnabled, feed.ShowUserFeedAtom) | ||
| m.Get("", user.Profile) | ||
| }, func(ctx *context.Context) { | ||
| ctx.Data["EnableFeed"] = setting.EnableFeed | ||
| }, context_service.UserAssignmentWeb()) | ||
| m.Get("/{username}", func(ctx *context.Context) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I think this function should get moved out of web.go and into a named function within routers/web/user - and we should probably also update the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the best case the upstream issue get solved ... the question is if we wana have that workaround now in or engineer around it properly ... or wait for upstream
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have personally given up on waiting for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well that would mean we must fix and submit a patch upstream 😆 |
||
| // WORKAROUND to support usernames with "." in it | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // https://github.com/go-chi/chi/issues/781 | ||
| username := ctx.Params("username") | ||
| reloadParam := func(suffix string) (success bool) { | ||
| ctx.SetParams("username", strings.TrimSuffix(username, suffix)) | ||
| context_service.UserAssignmentWeb()(ctx) | ||
| return !ctx.Written() | ||
| } | ||
| switch { | ||
| case strings.HasSuffix(username, ".keys"): | ||
| if reloadParam(".keys") { | ||
| user.ShowSSHKeys(ctx) | ||
| } | ||
| case strings.HasSuffix(username, ".gpg"): | ||
| if reloadParam(".gpg") { | ||
| user.ShowGPGKeys(ctx) | ||
| } | ||
| case strings.HasSuffix(username, ".rss"): | ||
| feedEnabled(ctx) | ||
| if !ctx.Written() && reloadParam(".rss") { | ||
| context_service.UserAssignmentWeb()(ctx) | ||
| feed.ShowUserFeedRSS(ctx) | ||
| } | ||
| case strings.HasSuffix(username, ".atom"): | ||
| feedEnabled(ctx) | ||
| if !ctx.Written() && reloadParam(".atom") { | ||
| feed.ShowUserFeedAtom(ctx) | ||
| } | ||
| default: | ||
| context_service.UserAssignmentWeb()(ctx) | ||
6543 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if !ctx.Written() { | ||
| ctx.Data["EnableFeed"] = setting.EnableFeed | ||
| user.Profile(ctx) | ||
| } | ||
| } | ||
| }) | ||
| m.Get("/attachments/{uuid}", repo.GetAttachment) | ||
| }, ignSignIn) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.