Skip to content

Commit bb317eb

Browse files
authored
Merge branch 'main' into introduce-tar-transform-to-prevent-tarbomb
2 parents bd82533 + ddbbe6e commit bb317eb

File tree

19 files changed

+49
-76
lines changed

19 files changed

+49
-76
lines changed

models/issue.go

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,8 @@ func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
11941194
// IssuesOptions represents options of an issue.
11951195
type IssuesOptions struct {
11961196
db.ListOptions
1197-
RepoIDs []int64 // include all repos if empty
1197+
RepoID int64 // overwrites RepoCond if not 0
1198+
RepoCond builder.Cond
11981199
AssigneeID int64
11991200
PosterID int64
12001201
MentionedID int64
@@ -1285,15 +1286,15 @@ func (opts *IssuesOptions) setupSessionNoLimit(sess *xorm.Session) {
12851286
sess.In("issue.id", opts.IssueIDs)
12861287
}
12871288

1288-
if len(opts.RepoIDs) > 0 {
1289-
applyReposCondition(sess, opts.RepoIDs)
1289+
if opts.RepoID != 0 {
1290+
opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoID}
1291+
}
1292+
if opts.RepoCond != nil {
1293+
sess.And(opts.RepoCond)
12901294
}
12911295

1292-
switch opts.IsClosed {
1293-
case util.OptionalBoolTrue:
1294-
sess.And("issue.is_closed=?", true)
1295-
case util.OptionalBoolFalse:
1296-
sess.And("issue.is_closed=?", false)
1296+
if !opts.IsClosed.IsNone() {
1297+
sess.And("issue.is_closed=?", opts.IsClosed.IsTrue())
12971298
}
12981299

12991300
if opts.AssigneeID > 0 {
@@ -1412,10 +1413,6 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati
14121413
return cond
14131414
}
14141415

1415-
func applyReposCondition(sess *xorm.Session, repoIDs []int64) *xorm.Session {
1416-
return sess.In("issue.repo_id", repoIDs)
1417-
}
1418-
14191416
func applyAssigneeCondition(sess *xorm.Session, assigneeID int64) *xorm.Session {
14201417
return sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
14211418
And("issue_assignees.assignee_id = ?", assigneeID)
@@ -1510,20 +1507,10 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
15101507
func CountIssues(opts *IssuesOptions) (int64, error) {
15111508
e := db.GetEngine(db.DefaultContext)
15121509

1513-
countsSlice := make([]*struct {
1514-
Count int64
1515-
}, 0, 1)
1516-
15171510
sess := e.Select("COUNT(issue.id) AS count").Table("issue")
15181511
sess.Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
15191512
opts.setupSessionNoLimit(sess)
1520-
if err := sess.Find(&countsSlice); err != nil {
1521-
return 0, fmt.Errorf("unable to CountIssues: %w", err)
1522-
}
1523-
if len(countsSlice) != 1 {
1524-
return 0, fmt.Errorf("unable to get one row result when CountIssues, row count=%d", len(countsSlice))
1525-
}
1526-
return countsSlice[0].Count, nil
1513+
return sess.Count()
15271514
}
15281515

15291516
// GetParticipantsIDsByIssueID returns the IDs of all users who participated in comments of an issue,

models/issue_label.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ func (label *Label) CalOpenIssues() {
5757

5858
// CalOpenOrgIssues calculates the open issues of a label for a specific repo
5959
func (label *Label) CalOpenOrgIssues(repoID, labelID int64) {
60-
repoIDs := []int64{repoID}
61-
labelIDs := []int64{labelID}
62-
6360
counts, _ := CountIssuesByRepo(&IssuesOptions{
64-
RepoIDs: repoIDs,
65-
LabelIDs: labelIDs,
61+
RepoID: repoID,
62+
LabelIDs: []int64{labelID},
6663
})
6764

6865
for _, count := range counts {

models/issue_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
user_model "code.gitea.io/gitea/models/user"
2222

2323
"github.com/stretchr/testify/assert"
24+
"xorm.io/builder"
2425
)
2526

2627
func TestIssue_ReplaceLabels(t *testing.T) {
@@ -157,7 +158,7 @@ func TestIssues(t *testing.T) {
157158
},
158159
{
159160
IssuesOptions{
160-
RepoIDs: []int64{1, 3},
161+
RepoCond: builder.In("repo_id", 1, 3),
161162
SortType: "oldest",
162163
ListOptions: db.ListOptions{
163164
Page: 1,
@@ -344,7 +345,7 @@ func TestGetRepoIDsForIssuesOptions(t *testing.T) {
344345
},
345346
{
346347
IssuesOptions{
347-
RepoIDs: []int64{1, 2},
348+
RepoCond: builder.In("repo_id", 1, 2),
348349
},
349350
[]int64{1, 2},
350351
},

modules/doctor/authorizedkeys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e
7272
"authorized_keys file %q is out of date.\nRegenerate it with:\n\t\"%s\"\nor\n\t\"%s\"",
7373
fPath,
7474
"gitea admin regenerate keys",
75-
"gitea doctor --run authorized_keys --fix")
76-
return fmt.Errorf(`authorized_keys is out of date and should be regenerated with "gitea admin regenerate keys" or "gitea doctor --run authorized_keys --fix"`)
75+
"gitea doctor --run authorized-keys --fix")
76+
return fmt.Errorf(`authorized_keys is out of date and should be regenerated with "gitea admin regenerate keys" or "gitea doctor --run authorized-keys --fix"`)
7777
}
7878
logger.Warn("authorized_keys is out of date. Attempting rewrite...")
7979
err = asymkey_model.RewriteAllPublicKeys()

modules/indexer/issues/indexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func populateIssueIndexer(ctx context.Context) {
321321
// UpdateRepoIndexer add/update all issues of the repositories
322322
func UpdateRepoIndexer(repo *repo_model.Repository) {
323323
is, err := models.Issues(&models.IssuesOptions{
324-
RepoIDs: []int64{repo.ID},
324+
RepoID: repo.ID,
325325
IsClosed: util.OptionalBoolNone,
326326
IsPull: util.OptionalBoolNone,
327327
})

modules/validation/helpers.go

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,10 @@ import (
1313
"code.gitea.io/gitea/modules/setting"
1414
)
1515

16-
var loopbackIPBlocks []*net.IPNet
17-
1816
var externalTrackerRegex = regexp.MustCompile(`({?)(?:user|repo|index)+?(}?)`)
1917

20-
func init() {
21-
for _, cidr := range []string{
22-
"127.0.0.0/8", // IPv4 loopback
23-
"::1/128", // IPv6 loopback
24-
} {
25-
if _, block, err := net.ParseCIDR(cidr); err == nil {
26-
loopbackIPBlocks = append(loopbackIPBlocks, block)
27-
}
28-
}
29-
}
30-
3118
func isLoopbackIP(ip string) bool {
32-
pip := net.ParseIP(ip)
33-
if pip == nil {
34-
return false
35-
}
36-
for _, block := range loopbackIPBlocks {
37-
if block.Contains(pip) {
38-
return true
39-
}
40-
}
41-
return false
19+
return net.ParseIP(ip).IsLoopback()
4220
}
4321

4422
// IsValidURL checks if URL is valid

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ error404 = The page you are trying to reach either <strong>does not exist</stron
105105

106106
never = Never
107107

108+
rss_feed = RSS Feed
109+
108110
[error]
109111
occurred = An error occurred
110112
report_message = If you are sure this is a Gitea bug, please search for issues on <a href="https://github.com/go-gitea/gitea/issues" target="_blank">GitHub</a> or open a new issue if necessary.

options/locale/locale_ja-JP.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,6 +3051,9 @@ container.labels.key=キー
30513051
container.labels.value=値
30523052
generic.download=コマンドラインでパッケージをダウンロードします:
30533053
generic.documentation=汎用 レジストリの詳細については、<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/generic">ドキュメント</a> を参照してください。
3054+
helm.registry=このレジストリをコマンドラインからセットアップします:
3055+
helm.install=パッケージをインストールするには、次のコマンドを実行します:
3056+
helm.documentation=Helm レジストリの詳細については、 <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/helm/">ドキュメント</a> を参照してください。
30543057
maven.registry=あなたのプロジェクトの <code>pom.xml</code> ファイルに、このレジストリをセットアップします:
30553058
maven.install=パッケージを使用するため <code>pom.xml</code> ファイル内の <code>dependencies</code> ブロックに以下を含めます:
30563059
maven.install2=コマンドラインで実行します:

options/locale/locale_pt-BR.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ organizations=Organizações
267267
search=Pesquisar
268268
code=Código
269269
search.fuzzy=Similar
270+
search.match=Correspondência
270271
code_search_unavailable=A pesquisa por código não está disponível no momento. Entre em contato com o administrador do site.
271272
repo_no_results=Nenhum repositório correspondente foi encontrado.
272273
user_no_results=Nenhum usuário correspondente foi encontrado.
@@ -566,6 +567,7 @@ comment_type_group_lock=Status de Bloqueio
566567
comment_type_group_review_request=Revisar solicitação
567568
comment_type_group_pull_request_push=Commits adicionados
568569
comment_type_group_project=Projeto
570+
comment_type_group_issue_ref=Referência do issue
569571
saved_successfully=Suas configurações foram salvas com sucesso.
570572
privacy=Privacidade
571573
keep_activity_private=Ocultar a atividade da página de perfil
@@ -2987,6 +2989,8 @@ empty.documentation=Para obter mais informações sobre o registro de pacote, co
29872989
filter.type=Tipo
29882990
filter.type.all=Todos
29892991
filter.no_result=Seu filtro não produziu resultados.
2992+
filter.container.tagged=Marcado
2993+
filter.container.untagged=Desmarcado
29902994
published_by=Publicado %[1]s por <a href="%[2]s">%[3]s</a>
29912995
published_by_in=Publicado %[1]s por <a href="%[2]s">%[3]s</a> em <a href="%[4]s"><strong>%[5]s</strong></a>
29922996
installation=Instalação
@@ -2998,6 +3002,7 @@ details=Detalhes
29983002
details.author=Autor
29993003
details.project_site=Site do Projeto
30003004
details.license=Licença
3005+
assets=Recursos
30013006
versions=Versões
30023007
versions.on=em
30033008
versions.view_all=Ver todas
@@ -3019,6 +3024,7 @@ container.details.documentation_site=Site da Documentação
30193024
container.pull=Puxe a imagem pela linha de comando:
30203025
container.documentation=Para obter mais informações sobre o registro de Container, consulte <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/container/">a documentação</a>.
30213026
container.multi_arch=S.O. / Arquitetura
3027+
container.layers=Camadas da Imagem
30223028
container.labels=Rótulos
30233029
container.labels.key=Chave
30243030
container.labels.value=Valor
@@ -3041,6 +3047,7 @@ npm.install2=ou adicione-o ao arquivo package.json:
30413047
npm.documentation=Para obter mais informações sobre o registro npm, consulte <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/npm/">a documentação</a>.
30423048
npm.dependencies=Dependências
30433049
npm.dependencies.development=Dependências de Desenvolvimento
3050+
npm.dependencies.peer=Dependências Peer
30443051
npm.dependencies.optional=Dependências Opcionais
30453052
npm.details.tag=Tag
30463053
pypi.requires=Requer Python

routers/api/v1/repo/issue.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func SearchIssues(ctx *context.APIContext) {
175175
opts.TeamID = team.ID
176176
}
177177

178+
repoCond := models.SearchRepositoryCondition(opts)
178179
repoIDs, _, err := models.SearchRepositoryIDs(opts)
179180
if err != nil {
180181
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
@@ -235,7 +236,7 @@ func SearchIssues(ctx *context.APIContext) {
235236
Page: ctx.FormInt("page"),
236237
PageSize: limit,
237238
},
238-
RepoIDs: repoIDs,
239+
RepoCond: repoCond,
239240
IsClosed: isClosed,
240241
IssueIDs: issueIDs,
241242
IncludedLabelNames: includedLabelNames,
@@ -462,7 +463,7 @@ func ListIssues(ctx *context.APIContext) {
462463
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
463464
issuesOpt := &models.IssuesOptions{
464465
ListOptions: listOptions,
465-
RepoIDs: []int64{ctx.Repo.Repository.ID},
466+
RepoID: ctx.Repo.Repository.ID,
466467
IsClosed: isClosed,
467468
IssueIDs: issueIDs,
468469
LabelIDs: labelIDs,

routers/web/repo/issue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
232232
Page: pager.Paginater.Current(),
233233
PageSize: setting.UI.IssuePagingNum,
234234
},
235-
RepoIDs: []int64{repo.ID},
235+
RepoID: repo.ID,
236236
AssigneeID: assigneeID,
237237
PosterID: posterID,
238238
MentionedID: mentionedID,
@@ -2167,6 +2167,7 @@ func SearchIssues(ctx *context.Context) {
21672167
opts.TeamID = team.ID
21682168
}
21692169

2170+
repoCond := models.SearchRepositoryCondition(opts)
21702171
repoIDs, _, err := models.SearchRepositoryIDs(opts)
21712172
if err != nil {
21722173
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err.Error())
@@ -2227,7 +2228,7 @@ func SearchIssues(ctx *context.Context) {
22272228
Page: ctx.FormInt("page"),
22282229
PageSize: limit,
22292230
},
2230-
RepoIDs: repoIDs,
2231+
RepoCond: repoCond,
22312232
IsClosed: isClosed,
22322233
IssueIDs: issueIDs,
22332234
IncludedLabelNames: includedLabelNames,
@@ -2403,7 +2404,7 @@ func ListIssues(ctx *context.Context) {
24032404
if len(keyword) == 0 || len(issueIDs) > 0 || len(labelIDs) > 0 {
24042405
issuesOpt := &models.IssuesOptions{
24052406
ListOptions: listOptions,
2406-
RepoIDs: []int64{ctx.Repo.Repository.ID},
2407+
RepoID: ctx.Repo.Repository.ID,
24072408
IsClosed: isClosed,
24082409
IssueIDs: issueIDs,
24092410
LabelIDs: labelIDs,

routers/web/user/home.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
463463
// to check if it's in the team(which possible isn't the case).
464464
opts.User = nil
465465
}
466-
userRepoIDs, _, err := models.SearchRepositoryIDs(repoOpts)
467-
if err != nil {
468-
ctx.ServerError("models.SearchRepositoryIDs: %v", err)
469-
return
470-
}
471-
472-
opts.RepoIDs = userRepoIDs
466+
opts.RepoCond = models.SearchRepositoryCondition(repoOpts)
473467
}
474468

475469
// keyword holds the search term entered into the search field.
@@ -533,7 +527,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
533527
// Gets set when clicking filters on the issues overview page.
534528
repoIDs := getRepoIDs(ctx.FormString("repos"))
535529
if len(repoIDs) > 0 {
536-
opts.RepoIDs = repoIDs
530+
opts.RepoCond = builder.In("issue.repo_id", repoIDs)
537531
}
538532

539533
// ------------------------------

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ func (g *GiteaLocalUploader) updateGitForPullRequest(pr *base.PullRequest) (head
553553
}
554554

555555
if ok {
556-
_, _, err = git.NewCommand(g.ctx, "fetch", remote, pr.Head.Ref).RunStdString(&git.RunOpts{Dir: g.repo.RepoPath()})
556+
_, _, err = git.NewCommand(g.ctx, "fetch", "--no-tags", "--", remote, pr.Head.Ref).RunStdString(&git.RunOpts{Dir: g.repo.RepoPath()})
557557
if err != nil {
558558
log.Error("Fetch branch from %s failed: %v", pr.Head.CloneURL, err)
559559
} else {

services/migrations/gitea_uploader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestGiteaUploadRepo(t *testing.T) {
105105
assert.Len(t, releases, 1)
106106

107107
issues, err := models.Issues(&models.IssuesOptions{
108-
RepoIDs: []int64{repo.ID},
108+
RepoID: repo.ID,
109109
IsPull: util.OptionalBoolFalse,
110110
SortType: "oldest",
111111
})

templates/org/home.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div id="org-info">
66
<div class="ui header">
77
{{.Org.DisplayName}}
8+
<a href="{{.Org.HomeLink}}.rss"><i class="ui grey icon tooltip ml-3" data-content="{{.i18n.Tr "rss_feed"}}" data-position="top center">{{svg "octicon-rss" 36}}</i></a>
89
<span class="org-visibility">
910
{{if .Org.Visibility.IsLimited}}<div class="ui large basic horizontal label">{{.i18n.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}}
1011
{{if .Org.Visibility.IsPrivate}}<div class="ui large basic horizontal label">{{.i18n.Tr "org.settings.visibility.private_shortname"}}</div>{{end}}

templates/repo/header.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
1414
<div class="mx-2">/</div>
1515
<a href="{{$.RepoLink}}">{{.Name}}</a>
16+
<a href="{{$.RepoLink}}.rss"><i class="ui grey icon tooltip ml-3" data-content="{{$.i18n.Tr "rss_feed"}}" data-position="top center">{{svg "octicon-rss" 18}}</i></a>
1617
<div class="labels df ac fw">
1718
{{if .IsTemplate}}
1819
{{if .IsPrivate}}

templates/user/profile.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<div class="content word-break profile-avatar-name">
1717
{{if .Owner.FullName}}<span class="header text center">{{.Owner.FullName}}</span>{{end}}
1818
<span class="username text center">{{.Owner.Name}}</span>
19+
<a href="{{.Owner.HomeLink}}.rss"><i class="ui grey icon tooltip ml-3" data-content="{{.i18n.Tr "rss_feed"}}" data-position="bottom center">{{svg "octicon-rss" 18}}</i></a>
1920
</div>
2021
<div class="extra content word-break">
2122
<ul>

web_src/less/_organization.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
overflow-wrap: anywhere;
5151

5252
.ui.header {
53+
display: flex;
54+
align-items: center;
5355
font-size: 36px;
5456
margin-bottom: 0;
5557
.org-visibility .label {

web_src/less/_user.less

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
.user {
44
&.profile {
55
.ui.card {
6-
.header,
7-
.username {
8-
display: block;
9-
}
10-
116
.header {
7+
display: block;
128
font-weight: 600;
139
font-size: 1.3rem;
1410
margin-top: -.2rem;
@@ -17,6 +13,7 @@
1713

1814
.profile-avatar-name {
1915
border-top: none;
16+
text-align: center;
2017
}
2118

2219
.extra.content {

0 commit comments

Comments
 (0)