Skip to content

Commit 799cd8b

Browse files
authored
Merge branch 'master' into 13682-review-requested-filter
2 parents 3edbbf2 + c09e11d commit 799cd8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+212
-280
lines changed

cmd/serv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func setup(logPath string, debug bool) {
5858
}
5959
setting.NewContext()
6060
if debug {
61-
setting.ProdMode = false
61+
setting.RunMode = "dev"
6262
}
6363
}
6464

@@ -76,7 +76,7 @@ func fail(userMessage, logMessage string, args ...interface{}) {
7676
fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
7777

7878
if len(logMessage) > 0 {
79-
if !setting.ProdMode {
79+
if !setting.IsProd() {
8080
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
8181
}
8282
}

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ MACARON = file
867867
ROUTER_LOG_LEVEL = Info
868868
ROUTER = console
869869
ENABLE_ACCESS_LOG = false
870-
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
870+
ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
871871
ACCESS = file
872872
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
873873
LEVEL = Info

models/models.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ func NewTestEngine() (err error) {
175175
}
176176

177177
x.SetMapper(names.GonicMapper{})
178-
x.SetLogger(NewXORMLogger(!setting.ProdMode))
179-
x.ShowSQL(!setting.ProdMode)
178+
x.SetLogger(NewXORMLogger(!setting.IsProd()))
179+
x.ShowSQL(!setting.IsProd())
180180
return x.StoreEngine("InnoDB").Sync2(tables...)
181181
}
182182

models/webhook.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,6 @@ func GetWebhooksByOrgID(orgID int64, listOptions ListOptions) ([]*Webhook, error
400400
return ws, sess.Find(&ws, &Webhook{OrgID: orgID})
401401
}
402402

403-
// GetDefaultWebhook returns admin-default webhook by given ID.
404-
func GetDefaultWebhook(id int64) (*Webhook, error) {
405-
webhook := &Webhook{ID: id}
406-
has, err := x.
407-
Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, false).
408-
Get(webhook)
409-
if err != nil {
410-
return nil, err
411-
} else if !has {
412-
return nil, ErrWebhookNotExist{id}
413-
}
414-
return webhook, nil
415-
}
416-
417403
// GetDefaultWebhooks returns all admin-default webhooks.
418404
func GetDefaultWebhooks() ([]*Webhook, error) {
419405
return getDefaultWebhooks(x)
@@ -426,11 +412,11 @@ func getDefaultWebhooks(e Engine) ([]*Webhook, error) {
426412
Find(&webhooks)
427413
}
428414

429-
// GetSystemWebhook returns admin system webhook by given ID.
430-
func GetSystemWebhook(id int64) (*Webhook, error) {
415+
// GetSystemOrDefaultWebhook returns admin system or default webhook by given ID.
416+
func GetSystemOrDefaultWebhook(id int64) (*Webhook, error) {
431417
webhook := &Webhook{ID: id}
432418
has, err := x.
433-
Where("repo_id=? AND org_id=? AND is_system_webhook=?", 0, 0, true).
419+
Where("repo_id=? AND org_id=?", 0, 0).
434420
Get(webhook)
435421
if err != nil {
436422
return nil, err

modules/auth/sso/sspi_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (s *SSPI) Init() error {
5656
Funcs: templates.NewFuncMap(),
5757
Asset: templates.GetAsset,
5858
AssetNames: templates.GetAssetNames,
59-
IsDevelopment: setting.RunMode != "prod",
59+
IsDevelopment: !setting.IsProd(),
6060
})
6161
return nil
6262
}
@@ -95,7 +95,7 @@ func (s *SSPI) VerifyAuthData(req *http.Request, w http.ResponseWriter, store Da
9595
// to login with another authentication method if SSPI authentication
9696
// fails
9797
store.GetData()["Flash"] = map[string]string{
98-
"ErrMsg": err.Error(),
98+
"ErrorMsg": err.Error(),
9999
}
100100
store.GetData()["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
101101
store.GetData()["EnableSSPI"] = true

modules/base/tool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const sniffLen = 512
3535
// SVGMimeType MIME type of SVG images.
3636
const SVGMimeType = "image/svg+xml"
3737

38-
var svgTagRegex = regexp.MustCompile(`(?s)\A\s*(?:<!--.*?-->\s*)*<svg\b`)
39-
var svgTagInXMLRegex = regexp.MustCompile(`(?s)\A<\?xml\b.*?\?>\s*(?:<!--.*?-->\s*)*<svg\b`)
38+
var svgTagRegex = regexp.MustCompile(`(?si)\A\s*(?:(<!--.*?-->|<!DOCTYPE\s+svg([\s:]+.*?>|>))\s*)*<svg[\s>\/]`)
39+
var svgTagInXMLRegex = regexp.MustCompile(`(?si)\A<\?xml\b.*?\?>\s*(?:(<!--.*?-->|<!DOCTYPE\s+svg([\s:]+.*?>|>))\s*)*<svg[\s>\/]`)
4040

4141
// EncodeMD5 encodes string to md5 hex value.
4242
func EncodeMD5(str string) string {

modules/base/tool_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ func TestIsSVGImageFile(t *testing.T) {
216216
assert.True(t, IsSVGImageFile([]byte(`<!-- Multiline
217217
Comment -->
218218
<svg></svg>`)))
219+
assert.True(t, IsSVGImageFile([]byte(`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN"
220+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
221+
<svg></svg>`)))
219222
assert.True(t, IsSVGImageFile([]byte(`<?xml version="1.0" encoding="UTF-8"?>
220223
<!-- Comment -->
221224
<svg></svg>`)))
@@ -227,6 +230,11 @@ func TestIsSVGImageFile(t *testing.T) {
227230
<!-- Multline
228231
Comment -->
229232
<svg></svg>`)))
233+
assert.True(t, IsSVGImageFile([]byte(`<?xml version="1.0" encoding="UTF-8"?>
234+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
235+
<!-- Multline
236+
Comment -->
237+
<svg></svg>`)))
230238
assert.False(t, IsSVGImageFile([]byte{}))
231239
assert.False(t, IsSVGImageFile([]byte("svg")))
232240
assert.False(t, IsSVGImageFile([]byte("<svgfoo></svgfoo>")))

modules/httpcache/httpcache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
// GetCacheControl returns a suitable "Cache-Control" header value
1919
func GetCacheControl() string {
20-
if setting.RunMode == "dev" {
20+
if !setting.IsProd() {
2121
return "no-store"
2222
}
2323
return "private, max-age=" + strconv.FormatInt(int64(setting.StaticCacheTime.Seconds()), 10)

modules/setting/setting.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ var (
376376
CustomConf string
377377
PIDFile = "/run/gitea.pid"
378378
WritePIDFile bool
379-
ProdMode bool
380379
RunMode string
381380
RunUser string
382381
IsWindows bool
@@ -388,6 +387,11 @@ var (
388387
UILocation = time.Local
389388
)
390389

390+
// IsProd if it's a production mode
391+
func IsProd() bool {
392+
return strings.EqualFold(RunMode, "prod")
393+
}
394+
391395
func getAppPath() (string, error) {
392396
var appPath string
393397
var err error

options/locale/locale_cs-CZ.ini

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,8 +1997,6 @@ dashboard=Přehled
19971997
users=Uživatelské účty
19981998
organizations=Organizace
19991999
repositories=Repozitáře
2000-
hooks=Výchozí webové háčky
2001-
systemhooks=Systémové webové háčky
20022000
authentication=Zdroje ověření
20032001
emails=Uživatelské e-maily
20042002
config=Nastavení
@@ -2148,11 +2146,8 @@ repos.forks=Rozštěpení
21482146
repos.issues=Úkoly
21492147
repos.size=Velikost
21502148

2151-
hooks.desc=Webové háčky automaticky vytvářejí HTTP POST dotazy na server při určitých Gitea událostech. Webové háčky definované zde jsou výchozí a budou zkopírovány do všech nových repozitářů. Přečtěte si více v <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">průvodci webovými háčky</a>.
2152-
hooks.add_webhook=Přidat výchozí webový háček
2153-
hooks.update_webhook=Aktualizovat výchozí webový háček
21542149

2155-
systemhooks.desc=Webové háčky automaticky vytvářejí HTTP POST dotazy na server při určitých Gitea událostech. Webové háčky definované zde budou vykonány na všech repozitářích systému, proto prosím zvažte jakékoli důsledky, které to může mít na výkon. Přečtěte si více v <a target="_blank" rel="noopener" href="https://docs.gitea.io/en-us/webhooks/">průvodci webovými háčky</a>.
2150+
systemhooks=Systémové webové háčky
21562151
systemhooks.add_webhook=Přidat systémový webový háček
21572152
systemhooks.update_webhook=Aktualizovat systémový webový háček
21582153

0 commit comments

Comments
 (0)