Skip to content

Commit 3d84f1f

Browse files
authored
Merge branch 'master' into letsencrypt
2 parents 9042772 + 6c1a31f commit 3d84f1f

22 files changed

+332
-40
lines changed

README_ZH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## 目标
2222

23-
Gitea的首要目标是创建一个极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。我们采用Go作为后端语言,这使我们只要生成一个可执行程序即可。并且他还支持跨平台,支持 Linux, macOS 和 Windows 以及各种架构,除了x86,amd64,还包括 ARM 和 PowerPC。
23+
Gitea 的首要目标是创建一个极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。我们采用 Go 作为后端语言,这使我们只要生成一个可执行程序即可。并且他还支持跨平台,支持 Linux, macOS 和 Windows 以及各种架构,除了 x86,amd64,还包括 ARM 和 PowerPC。
2424

2525
如果您想试用一下,请访问 [在线Demo](https://try.gitea.io/)
2626

docker/etc/ssh/sshd_config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ AllowUsers git
2929

3030
Banner none
3131
Subsystem sftp /usr/lib/ssh/sftp-server
32-
UsePrivilegeSeparation no

models/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
964964

965965
// Insert the assignees
966966
for _, assigneeID := range opts.AssigneeIDs {
967-
err = opts.Issue.changeAssignee(e, doer, assigneeID)
967+
err = opts.Issue.changeAssignee(e, doer, assigneeID, true)
968968
if err != nil {
969969
return err
970970
}

models/issue_assignees.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
134134
return err
135135
}
136136

137-
if err := issue.changeAssignee(sess, doer, assigneeID); err != nil {
137+
if err := issue.changeAssignee(sess, doer, assigneeID, false); err != nil {
138138
return err
139139
}
140140

141141
return sess.Commit()
142142
}
143143

144-
func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID int64) (err error) {
144+
func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID int64, isCreate bool) (err error) {
145145

146146
// Update the assignee
147147
removed, err := updateIssueAssignee(sess, issue, assigneeID)
@@ -161,6 +161,10 @@ func (issue *Issue) changeAssignee(sess *xorm.Session, doer *User, assigneeID in
161161

162162
mode, _ := accessLevel(sess, doer.ID, issue.Repo)
163163
if issue.IsPull {
164+
// if pull request is in the middle of creation - don't call webhook
165+
if isCreate {
166+
return nil
167+
}
164168
if err = issue.loadPullRequest(sess); err != nil {
165169
return fmt.Errorf("loadPullRequest: %v", err)
166170
}

modules/validation/binding.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package validation
66

77
import (
88
"fmt"
9-
"net/url"
109
"regexp"
1110
"strings"
1211

@@ -70,13 +69,9 @@ func addValidURLBindingRule() {
7069
},
7170
IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) {
7271
str := fmt.Sprintf("%v", val)
73-
if len(str) != 0 {
74-
if u, err := url.ParseRequestURI(str); err != nil ||
75-
(u.Scheme != "http" && u.Scheme != "https") ||
76-
!validPort(portOnly(u.Host)) {
77-
errs.Add([]string{name}, binding.ERR_URL, "Url")
78-
return false, errs
79-
}
72+
if len(str) != 0 && !IsValidURL(str) {
73+
errs.Add([]string{name}, binding.ERR_URL, "Url")
74+
return false, errs
8075
}
8176

8277
return true, errs

modules/validation/helpers.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package validation
6+
7+
import (
8+
"net"
9+
"net/url"
10+
"strings"
11+
12+
"code.gitea.io/gitea/modules/setting"
13+
)
14+
15+
var loopbackIPBlocks []*net.IPNet
16+
17+
func init() {
18+
for _, cidr := range []string{
19+
"127.0.0.0/8", // IPv4 loopback
20+
"::1/128", // IPv6 loopback
21+
} {
22+
if _, block, err := net.ParseCIDR(cidr); err == nil {
23+
loopbackIPBlocks = append(loopbackIPBlocks, block)
24+
}
25+
}
26+
}
27+
28+
func isLoopbackIP(ip string) bool {
29+
pip := net.ParseIP(ip)
30+
if pip == nil {
31+
return false
32+
}
33+
for _, block := range loopbackIPBlocks {
34+
if block.Contains(pip) {
35+
return true
36+
}
37+
}
38+
return false
39+
}
40+
41+
// IsValidURL checks if URL is valid
42+
func IsValidURL(uri string) bool {
43+
if u, err := url.ParseRequestURI(uri); err != nil ||
44+
(u.Scheme != "http" && u.Scheme != "https") ||
45+
!validPort(portOnly(u.Host)) {
46+
return false
47+
}
48+
49+
return true
50+
}
51+
52+
// IsAPIURL checks if URL is current Gitea instance API URL
53+
func IsAPIURL(uri string) bool {
54+
return strings.HasPrefix(strings.ToLower(uri), strings.ToLower(setting.AppURL+"api"))
55+
}
56+
57+
// IsValidExternalURL checks if URL is valid external URL
58+
func IsValidExternalURL(uri string) bool {
59+
if !IsValidURL(uri) || IsAPIURL(uri) {
60+
return false
61+
}
62+
63+
u, err := url.ParseRequestURI(uri)
64+
if err != nil {
65+
return false
66+
}
67+
68+
// Currently check only if not loopback IP is provided to keep compatibility
69+
if isLoopbackIP(u.Hostname()) || strings.ToLower(u.Hostname()) == "localhost" {
70+
return false
71+
}
72+
73+
// TODO: Later it should be added to allow local network IP addreses
74+
// only if allowed by special setting
75+
76+
return true
77+
}

modules/validation/helpers_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package validation
6+
7+
import (
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
12+
"code.gitea.io/gitea/modules/setting"
13+
)
14+
15+
func Test_IsValidURL(t *testing.T) {
16+
cases := []struct {
17+
description string
18+
url string
19+
valid bool
20+
}{
21+
{
22+
description: "Empty URL",
23+
url: "",
24+
valid: false,
25+
},
26+
{
27+
description: "Loobpack IPv4 URL",
28+
url: "http://127.0.1.1:5678/",
29+
valid: true,
30+
},
31+
{
32+
description: "Loobpack IPv6 URL",
33+
url: "https://[::1]/",
34+
valid: true,
35+
},
36+
{
37+
description: "Missing semicolon after schema",
38+
url: "http//meh/",
39+
valid: false,
40+
},
41+
}
42+
43+
for _, testCase := range cases {
44+
t.Run(testCase.description, func(t *testing.T) {
45+
assert.Equal(t, testCase.valid, IsValidURL(testCase.url))
46+
})
47+
}
48+
}
49+
50+
func Test_IsValidExternalURL(t *testing.T) {
51+
setting.AppURL = "https://try.gitea.io/"
52+
53+
cases := []struct {
54+
description string
55+
url string
56+
valid bool
57+
}{
58+
{
59+
description: "Current instance URL",
60+
url: "https://try.gitea.io/test",
61+
valid: true,
62+
},
63+
{
64+
description: "Loobpack IPv4 URL",
65+
url: "http://127.0.1.1:5678/",
66+
valid: false,
67+
},
68+
{
69+
description: "Current instance API URL",
70+
url: "https://try.gitea.io/api/v1/user/follow",
71+
valid: false,
72+
},
73+
{
74+
description: "Local network URL",
75+
url: "http://192.168.1.2/api/v1/user/follow",
76+
valid: true,
77+
},
78+
{
79+
description: "Local URL",
80+
url: "http://LOCALHOST:1234/whatever",
81+
valid: false,
82+
},
83+
}
84+
85+
for _, testCase := range cases {
86+
t.Run(testCase.description, func(t *testing.T) {
87+
assert.Equal(t, testCase.valid, IsValidExternalURL(testCase.url))
88+
})
89+
}
90+
}

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,6 @@ settings.event_push=Push
10711071
settings.event_push_desc=Git push in ein Repository.
10721072
settings.event_repository=Repository
10731073
settings.event_repository_desc=Repository erstellt oder gelöscht.
1074-
settings.active=Event-Details mitversenden
1075-
settings.active_helper=Informationen über das auslösende Event mitversenden.
10761074
settings.add_hook_success=Webhook wurde hinzugefügt.
10771075
settings.update_webhook=Webhook aktualisieren
10781076
settings.update_hook_success=Webhook wurde aktualisiert.

options/locale/locale_en-US.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ issues.dependency.add_error_dep_not_exist = Dependency does not exist.
814814
issues.dependency.add_error_dep_exists = Dependency already exists.
815815
issues.dependency.add_error_cannot_create_circular = You cannot create a dependency with two issues blocking each other.
816816
issues.dependency.add_error_dep_not_same_repo = Both issues must be in the same repository.
817+
issues.review.self.approval = You cannot approve your own pull request.
818+
issues.review.self.rejection = You cannot request changes on your own pull request.
817819
issues.review.approve = "approved these changes %s"
818820
issues.review.comment = "reviewed %s"
819821
issues.review.content.empty = You need to leave a comment indicating the requested change(s).
@@ -987,6 +989,7 @@ settings.external_tracker_url = External Issue Tracker URL
987989
settings.external_tracker_url_error = The external issue tracker URL is not a valid URL.
988990
settings.external_tracker_url_desc = Visitors are redirected to the external issue tracker URL when clicking on the issues tab.
989991
settings.tracker_url_format = External Issue Tracker URL Format
992+
settings.tracker_url_format_error = The external issue tracker URL format is not a valid URL.
990993
settings.tracker_issue_style = External Issue Tracker Number Format
991994
settings.tracker_issue_style.numeric = Numeric
992995
settings.tracker_issue_style.alphanumeric = Alphanumeric
@@ -1088,8 +1091,8 @@ settings.event_push = Push
10881091
settings.event_push_desc = Git push to a repository.
10891092
settings.event_repository = Repository
10901093
settings.event_repository_desc = Repository created or deleted.
1091-
settings.active = Include Event Details
1092-
settings.active_helper = Add information about the triggering event to requests.
1094+
settings.active = Active
1095+
settings.active_helper = Information about triggered events will be sent to this webhook URL.
10931096
settings.add_hook_success = The webhook has been added.
10941097
settings.update_webhook = Update Webhook
10951098
settings.update_hook_success = The webhook has been updated.
@@ -1311,6 +1314,7 @@ teams.search_repo_placeholder = Search repository…
13111314
teams.add_team_repository = Add Team Repository
13121315
teams.remove_repo = Remove
13131316
teams.add_nonexistent_repo = "The repository you're trying to add does not exist; please create it first."
1317+
teams.add_duplicate_users = User is already a team member.
13141318

13151319
[admin]
13161320
dashboard = Dashboard

options/locale/locale_fr-FR.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,8 +1054,6 @@ settings.event_push=Pousser
10541054
settings.event_push_desc=Git push vers un dépôt.
10551055
settings.event_repository=Dépôt
10561056
settings.event_repository_desc=Dépôt créé ou supprimé.
1057-
settings.active=Inclure les détails de l'événement
1058-
settings.active_helper=Ajouter des informations sur l’événement déclencheur aux requêtes.
10591057
settings.add_hook_success=Nouveau Webhook ajouté.
10601058
settings.update_webhook=Mettre à jour le Webhook
10611059
settings.update_hook_success=Webhook mis à jour.

options/locale/locale_it-IT.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,6 @@ settings.event_push=Push
10211021
settings.event_push_desc=Git push in un repository.
10221022
settings.event_repository=Repository
10231023
settings.event_repository_desc=Repository creato o eliminato.
1024-
settings.active=Includi dettagli evento
1025-
settings.active_helper=Aggiunge alle richieste informazioni riguardo la causa.
10261024
settings.add_hook_success=Il webhook è stato aggiunto.
10271025
settings.update_webhook=Aggiorna Webhook
10281026
settings.update_hook_success=Il webhook è stato aggiornato.

options/locale/locale_lv-LV.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ settings.external_tracker_url=Ārējā problēmu reģistra URL
987987
settings.external_tracker_url_error=Nekorekts ārējā problēmu sekotāja URL.
988988
settings.external_tracker_url_desc=Apmeklētāji tiks novirzīti uz ārējā problēmu sekotāja adresi, kad uzklikšķinās uz cilnes.
989989
settings.tracker_url_format=Ārējā problēmu sekotāja adreses formāts
990+
settings.tracker_url_format_error=Ārējā problēmu sekotāja URL formāts nav korekts URL.
990991
settings.tracker_issue_style=Ārējā problēmu sekotāja numura formāts
991992
settings.tracker_issue_style.numeric=Cipari
992993
settings.tracker_issue_style.alphanumeric=Burti un cipari
@@ -1088,8 +1089,8 @@ settings.event_push=Izmaiņu nosūtīšana
10881089
settings.event_push_desc=Git izmaiņu nosūtīšana uz repozitoriju.
10891090
settings.event_repository=Repozitorijs
10901091
settings.event_repository_desc=Repozitorijs izveidots vai dzēsts.
1091-
settings.active=Iekļaut notikuma detaļas
1092-
settings.active_helper=Pievienot pieprasījumam informāciju par notikuma izcelsmi.
1092+
settings.active=Aktīvs
1093+
settings.active_helper=Informācija par notikumiem tiks nosūtīta uz šo tīmekļa āķa URL.
10931094
settings.add_hook_success=Tīmekļa āķis tika pievienots.
10941095
settings.update_webhook=Mainīt tīmekļa āķi
10951096
settings.update_hook_success=Tīmekļa āķis tika atjaunots.
@@ -1152,6 +1153,11 @@ diff.data_not_available=Satura salīdzināšana nav pieejama
11521153
diff.show_diff_stats=Rādīt salīdzināšanas statistiku
11531154
diff.show_split_view=Dalītais skats
11541155
diff.show_unified_view=Apvienotais skats
1156+
diff.whitespace_button=Atstarpes
1157+
diff.whitespace_show_everything=Rādīt visas izmaiņas
1158+
diff.whitespace_ignore_all_whitespace=Ignorēt atstarpes salīdzinot rindas
1159+
diff.whitespace_ignore_amount_changes=Ignorēt atstarpju daudzuma izmaiņas
1160+
diff.whitespace_ignore_at_eol=Ignorēt atstarpju izmaiņas rindu beigās
11551161
diff.stats_desc=<strong>%d mainītis faili</strong> ar <strong>%d papildinājumiem</strong> un <strong>%d dzēšanām</strong>
11561162
diff.bin=Binārs
11571163
diff.view_file=Parādīt failu

options/locale/locale_pt-BR.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ settings.external_tracker_url=URL do issue tracker externo
987987
settings.external_tracker_url_error=A URL do issue tracker externo não é válida.
988988
settings.external_tracker_url_desc=Visitantes são redirecionados para a URL do issue tracker externo ao clicar na aba de issues.
989989
settings.tracker_url_format=Formato de URL do issue tracker externo
990+
settings.tracker_url_format_error=O formato da URL do issue tracker externo não é válido.
990991
settings.tracker_issue_style=Formato de número do issue tracker externo
991992
settings.tracker_issue_style.numeric=Numérico
992993
settings.tracker_issue_style.alphanumeric=Alfanumérico
@@ -1088,8 +1089,8 @@ settings.event_push=Push
10881089
settings.event_push_desc=Git push para o repositório.
10891090
settings.event_repository=Repositório
10901091
settings.event_repository_desc=Repositório criado ou excluído.
1091-
settings.active=Incluir detalhes do evento
1092-
settings.active_helper=Adicione informações sobre o evento de acionamento para requisições.
1092+
settings.active=Ativo
1093+
settings.active_helper=Informações sobre eventos disparados serão enviadas para esta URL do webhook.
10931094
settings.add_hook_success=O webhook foi adicionado.
10941095
settings.update_webhook=Atualizar webhook
10951096
settings.update_hook_success=O webhook foi atualizado.
@@ -1152,6 +1153,11 @@ diff.data_not_available=Conteúdo de diff não disponível
11521153
diff.show_diff_stats=Mostrar estatísticas do Diff
11531154
diff.show_split_view=Visão dividida
11541155
diff.show_unified_view=Visão unificada
1156+
diff.whitespace_button=Espaço em branco
1157+
diff.whitespace_show_everything=Mostrar todas as alterações
1158+
diff.whitespace_ignore_all_whitespace=Ignorar todas as alterações de espaço em branco
1159+
diff.whitespace_ignore_amount_changes=Ignorar alterações na quantidade de espaço em branco
1160+
diff.whitespace_ignore_at_eol=Ignorar alterações com espaço em branco no final da linha
11551161
diff.stats_desc=<strong> %d arquivos alterados</strong> com <strong>%d adições</strong> e <strong>%d exclusões</strong>
11561162
diff.bin=BIN
11571163
diff.view_file=Ver arquivo

0 commit comments

Comments
 (0)