Skip to content

Commit f1ddccf

Browse files
Merge branch 'main' into add-repo-license-display
2 parents 8991c24 + 1fede04 commit f1ddccf

File tree

14 files changed

+282
-346
lines changed

14 files changed

+282
-346
lines changed

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module code.gitea.io/gitea
22

33
go 1.23
44

5+
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
6+
// But some CAs use negative serial number, just relax the check. related:
7+
// Default TLS cert uses negative serial number #895 https://github.com/microsoft/mssql-docker/issues/895
8+
godebug x509negativeserial=1
9+
510
require (
611
code.gitea.io/actions-proto-go v0.4.0
712
code.gitea.io/gitea-vet v0.2.3

models/repo/release.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ type FindReleasesOptions struct {
234234
IsDraft optional.Option[bool]
235235
TagNames []string
236236
HasSha1 optional.Option[bool] // useful to find draft releases which are created with existing tags
237+
NamePattern optional.Option[string]
237238
}
238239

239240
func (opts FindReleasesOptions) ToConds() builder.Cond {
@@ -261,6 +262,11 @@ func (opts FindReleasesOptions) ToConds() builder.Cond {
261262
cond = cond.And(builder.Eq{"sha1": ""})
262263
}
263264
}
265+
266+
if opts.NamePattern.Has() && opts.NamePattern.Value() != "" {
267+
cond = cond.And(builder.Like{"lower_tag_name", strings.ToLower(opts.NamePattern.Value())})
268+
}
269+
264270
return cond
265271
}
266272

modules/templates/util_avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
3434
name = "avatar"
3535
}
3636

37-
return template.HTML(`<img class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
37+
return template.HTML(`<img loading="lazy" class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
3838
}
3939

4040
// Avatar renders user avatars. args: user, size (int), class (string)

options/locale/locale_en-US.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ code_search_by_git_grep = Current code search results are provided by "git grep"
178178
package_kind = Search packages...
179179
project_kind = Search projects...
180180
branch_kind = Search branches...
181+
tag_kind = Search tags...
182+
tag_tooltip = Search for matching tags. Use '%' to match any sequence of numbers.
181183
commit_kind = Search commits...
182184
runner_kind = Search runners...
183185
no_results = No matching results found.
@@ -220,8 +222,6 @@ string.desc = Z - A
220222
[error]
221223
occurred = An error occurred
222224
report_message = If you believe that this is a Gitea bug, please search for issues on <a href="%s" target="_blank">GitHub</a> or open a new issue if necessary.
223-
missing_csrf = Bad Request: no CSRF token present
224-
invalid_csrf = Bad Request: invalid CSRF token
225225
not_found = The target couldn't be found.
226226
network_error = Network error
227227

routers/web/repo/release.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ func TagsList(ctx *context.Context) {
214214
ctx.Data["HideBranchesInDropdown"] = true
215215
ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived
216216

217+
namePattern := ctx.FormTrim("q")
218+
217219
listOptions := db.ListOptions{
218220
Page: ctx.FormInt("page"),
219221
PageSize: ctx.FormInt("limit"),
@@ -233,6 +235,7 @@ func TagsList(ctx *context.Context) {
233235
IncludeTags: true,
234236
HasSha1: optional.Some(true),
235237
RepoID: ctx.Repo.Repository.ID,
238+
NamePattern: optional.Some(namePattern),
236239
}
237240

238241
releases, err := db.Find[repo_model.Release](ctx, opts)
@@ -241,14 +244,21 @@ func TagsList(ctx *context.Context) {
241244
return
242245
}
243246

247+
count, err := db.Count[repo_model.Release](ctx, opts)
248+
if err != nil {
249+
ctx.ServerError("GetReleasesByRepoID", err)
250+
return
251+
}
252+
253+
ctx.Data["Keyword"] = namePattern
244254
ctx.Data["Releases"] = releases
255+
ctx.Data["TagCount"] = count
245256

246-
numTags := ctx.Data["NumTags"].(int64)
247-
pager := context.NewPagination(int(numTags), opts.PageSize, opts.Page, 5)
257+
pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5)
248258
pager.SetDefaultParams(ctx)
249259
ctx.Data["Page"] = pager
250-
251260
ctx.Data["PageIsViewCode"] = !ctx.Repo.Repository.UnitEnabled(ctx, unit.TypeReleases)
261+
252262
ctx.HTML(http.StatusOK, tplTagsList)
253263
}
254264

routers/web/web.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ func webAuth(authMethod auth_service.Method) func(*context.Context) {
129129
// ensure the session uid is deleted
130130
_ = ctx.Session.Delete("uid")
131131
}
132+
133+
ctx.Csrf.PrepareForSessionUser(ctx)
132134
}
133135
}
134136

services/context/context.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ func Contexter() func(next http.Handler) http.Handler {
138138
csrfOpts := CsrfOptions{
139139
Secret: hex.EncodeToString(setting.GetGeneralTokenSigningSecret()),
140140
Cookie: setting.CSRFCookieName,
141-
SetCookie: true,
142141
Secure: setting.SessionConfig.Secure,
143142
CookieHTTPOnly: setting.CSRFCookieHTTPOnly,
144-
Header: "X-Csrf-Token",
145143
CookieDomain: setting.SessionConfig.Domain,
146144
CookiePath: setting.SessionConfig.CookiePath,
147145
SameSite: setting.SessionConfig.SameSite,
@@ -167,7 +165,7 @@ func Contexter() func(next http.Handler) http.Handler {
167165
ctx.Base.AppendContextValue(WebContextKey, ctx)
168166
ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
169167

170-
ctx.Csrf = PrepareCSRFProtector(csrfOpts, ctx)
168+
ctx.Csrf = NewCSRFProtector(csrfOpts)
171169

172170
// Get the last flash message from cookie
173171
lastFlashCookie := middleware.GetSiteCookie(ctx.Req, CookieNameFlash)
@@ -204,8 +202,6 @@ func Contexter() func(next http.Handler) http.Handler {
204202
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
205203

206204
ctx.Data["SystemConfig"] = setting.Config()
207-
ctx.Data["CsrfToken"] = ctx.Csrf.GetToken()
208-
ctx.Data["CsrfTokenHtml"] = template.HTML(`<input type="hidden" name="_csrf" value="` + ctx.Data["CsrfToken"].(string) + `">`)
209205

210206
// FIXME: do we really always need these setting? There should be someway to have to avoid having to always set these
211207
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations

0 commit comments

Comments
 (0)