Skip to content

Commit 5f81fe7

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix project description rendering for org (go-gitea#30587) Fix changelog (main) (go-gitea#30582) Avoid importing `modules/web/middleware` in `modules/session` (go-gitea#30584) Enable npm cache on `setup-node` action (go-gitea#30577)
2 parents f3b81c7 + eb24d97 commit 5f81fe7

File tree

10 files changed

+5401
-5228
lines changed

10 files changed

+5401
-5228
lines changed

.github/workflows/pull-compliance.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
- uses: actions/setup-node@v4
3939
with:
4040
node-version: 20
41+
cache: npm
42+
cache-dependency-path: package-lock.json
4143
- run: pip install poetry
4244
- run: make deps-py
4345
- run: make deps-frontend
@@ -65,6 +67,8 @@ jobs:
6567
- uses: actions/setup-node@v4
6668
with:
6769
node-version: 20
70+
cache: npm
71+
cache-dependency-path: package-lock.json
6872
- run: make deps-frontend
6973
- run: make lint-swagger
7074

@@ -134,6 +138,8 @@ jobs:
134138
- uses: actions/setup-node@v4
135139
with:
136140
node-version: 20
141+
cache: npm
142+
cache-dependency-path: package-lock.json
137143
- run: make deps-frontend
138144
- run: make lint-frontend
139145
- run: make checks-frontend
@@ -181,6 +187,8 @@ jobs:
181187
- uses: actions/setup-node@v4
182188
with:
183189
node-version: 20
190+
cache: npm
191+
cache-dependency-path: package-lock.json
184192
- run: make deps-frontend
185193
- run: make lint-md
186194
- run: make docs

.github/workflows/pull-e2e-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- uses: actions/setup-node@v4
2525
with:
2626
node-version: 20
27+
cache: npm
28+
cache-dependency-path: package-lock.json
2729
- run: make deps-frontend frontend deps-backend
2830
- run: npx playwright install --with-deps
2931
- run: make test-e2e-sqlite

.github/workflows/release-nightly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- uses: actions/setup-node@v4
2626
with:
2727
node-version: 20
28+
cache: npm
29+
cache-dependency-path: package-lock.json
2830
- run: make deps-frontend deps-backend
2931
# xgo build
3032
- run: make release

.github/workflows/release-tag-rc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- uses: actions/setup-node@v4
2525
with:
2626
node-version: 20
27+
cache: npm
28+
cache-dependency-path: package-lock.json
2729
- run: make deps-frontend deps-backend
2830
# xgo build
2931
- run: make release

.github/workflows/release-tag-version.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
- uses: actions/setup-node@v4
2727
with:
2828
node-version: 20
29+
cache: npm
30+
cache-dependency-path: package-lock.json
2931
- run: make deps-frontend deps-backend
3032
# xgo build
3133
- run: make release

CHANGELOG-archived.md

Lines changed: 5223 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 142 additions & 5216 deletions
Large diffs are not rendered by default.

modules/session/store.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ package session
66
import (
77
"net/http"
88

9-
"code.gitea.io/gitea/modules/setting"
10-
"code.gitea.io/gitea/modules/web/middleware"
11-
129
"gitea.com/go-chi/session"
1310
)
1411

@@ -21,10 +18,12 @@ type Store interface {
2118

2219
// RegenerateSession regenerates the underlying session and returns the new store
2320
func RegenerateSession(resp http.ResponseWriter, req *http.Request) (Store, error) {
24-
// Ensure that a cookie with a trailing slash does not take precedence over
25-
// the cookie written by the middleware.
26-
middleware.DeleteLegacySiteCookie(resp, setting.SessionConfig.CookieName)
27-
21+
for _, f := range BeforeRegenerateSession {
22+
f(resp, req)
23+
}
2824
s, err := session.RegenerateSession(resp, req)
2925
return s, err
3026
}
27+
28+
// BeforeRegenerateSession is a list of functions that are called before a session is regenerated.
29+
var BeforeRegenerateSession []func(http.ResponseWriter, *http.Request)

modules/web/middleware/cookie.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net/url"
1010
"strings"
1111

12+
"code.gitea.io/gitea/modules/session"
1213
"code.gitea.io/gitea/modules/setting"
1314
)
1415

@@ -48,12 +49,12 @@ func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
4849
// Previous versions would use a cookie path with a trailing /.
4950
// These are more specific than cookies without a trailing /, so
5051
// we need to delete these if they exist.
51-
DeleteLegacySiteCookie(resp, name)
52+
deleteLegacySiteCookie(resp, name)
5253
}
5354

54-
// DeleteLegacySiteCookie deletes the cookie with the given name at the cookie
55+
// deleteLegacySiteCookie deletes the cookie with the given name at the cookie
5556
// path with a trailing /, which would unintentionally override the cookie.
56-
func DeleteLegacySiteCookie(resp http.ResponseWriter, name string) {
57+
func deleteLegacySiteCookie(resp http.ResponseWriter, name string) {
5758
if setting.SessionConfig.CookiePath == "" || strings.HasSuffix(setting.SessionConfig.CookiePath, "/") {
5859
// If the cookie path ends with /, no legacy cookies will take
5960
// precedence, so do nothing. The exception is that cookies with no
@@ -74,3 +75,11 @@ func DeleteLegacySiteCookie(resp http.ResponseWriter, name string) {
7475
}
7576
resp.Header().Add("Set-Cookie", cookie.String())
7677
}
78+
79+
func init() {
80+
session.BeforeRegenerateSession = append(session.BeforeRegenerateSession, func(resp http.ResponseWriter, _ *http.Request) {
81+
// Ensure that a cookie with a trailing slash does not take precedence over
82+
// the cookie written by the middleware.
83+
deleteLegacySiteCookie(resp, setting.SessionConfig.CookieName)
84+
})
85+
}

routers/web/org/projects.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func Projects(ctx *context.Context) {
104104
}
105105

106106
for _, project := range projects {
107-
project.RenderedContent = templates.SanitizeHTML(project.Description) // FIXME: is it right? why not render?
107+
project.RenderedContent = templates.RenderMarkdownToHtml(ctx, project.Description)
108108
}
109109

110110
err = shared_user.LoadHeaderCount(ctx)
@@ -372,7 +372,7 @@ func ViewProject(ctx *context.Context) {
372372
}
373373
}
374374

375-
project.RenderedContent = templates.SanitizeHTML(project.Description) // FIXME: is it right? why not render?
375+
project.RenderedContent = templates.RenderMarkdownToHtml(ctx, project.Description)
376376
ctx.Data["LinkedPRs"] = linkedPrsMap
377377
ctx.Data["PageIsViewProjects"] = true
378378
ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)

0 commit comments

Comments
 (0)