Support "." char as user name for User/Orgs in RSS/ATOM/GPG/KEYS path ... (#23874)

- close #22301

workaround for https://github.com/go-chi/chi/issues/781
This commit is contained in:
6543 2023-04-07 12:08:36 +02:00 committed by GitHub
parent ca5722a0fa
commit 88033438aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 15 deletions

View file

@ -33,7 +33,7 @@ func TestNodeinfo(t *testing.T) {
DecodeJSON(t, resp, &nodeinfo)
assert.True(t, nodeinfo.OpenRegistrations)
assert.Equal(t, "gitea", nodeinfo.Software.Name)
assert.Equal(t, 24, nodeinfo.Usage.Users.Total)
assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
assert.Equal(t, 18, nodeinfo.Usage.LocalPosts)
assert.Equal(t, 2, nodeinfo.Usage.LocalComments)
})

View file

@ -25,7 +25,7 @@ func TestSettingShowUserEmailExplore(t *testing.T) {
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find(".ui.user.list").Text(),
"user4@example.com",
"user34@example.com",
)
setting.UI.ShowUserEmail = false
@ -35,7 +35,7 @@ func TestSettingShowUserEmailExplore(t *testing.T) {
htmlDoc = NewHTMLParser(t, resp.Body)
assert.NotContains(t,
htmlDoc.doc.Find(".ui.user.list").Text(),
"user4@example.com",
"user34@example.com",
)
setting.UI.ShowUserEmail = showUserEmail

View file

@ -241,6 +241,19 @@ func testExportUserGPGKeys(t *testing.T, user, expected string) {
assert.Equal(t, expected, resp.Body.String())
}
func TestGetUserRss(t *testing.T) {
user34 := "the_34-user.with.all.allowedChars"
req := NewRequestf(t, "GET", "/%s.rss", user34)
resp := MakeRequest(t, req, http.StatusOK)
if assert.EqualValues(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
rssDoc := NewHTMLParser(t, resp.Body).Find("channel")
title, _ := rssDoc.ChildrenFiltered("title").Html()
assert.EqualValues(t, "Feed of "the_1-user.with.all.allowedChars"", title)
description, _ := rssDoc.ChildrenFiltered("description").Html()
assert.EqualValues(t, "<p>some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
}
}
func TestListStopWatches(t *testing.T) {
defer tests.PrepareTestEnv(t)()