From 5cd887dba5dea90470435bfa338b70c5c036019e Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Mon, 9 Feb 2015 12:56:46 +0200 Subject: Fixes #921 Fixes #921 and makes the Mention regexp be in line with the others --- modules/base/markdown.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/base/markdown.go b/modules/base/markdown.go index b5f397dc..4a7adc8a 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -106,7 +106,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, } var ( - MentionPattern = regexp.MustCompile(`((^|\s)@)[0-9a-zA-Z_]{1,}`) + MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_]+`) commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`) issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`) issueIndexPattern = regexp.MustCompile(`( |^)#[0-9]+`) @@ -128,8 +128,9 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { if !inCodeBlock && !bytes.HasPrefix(line, tab) { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { + m = bytes.TrimSpace(m) line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[2:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[1:], m)), -1) } } -- cgit v1.2.3 From 6a23252edc36a3d99b35af69a310fd31f687f3cb Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 10 Feb 2015 21:06:59 -0500 Subject: able to allow insecure certification of webhook for #891 --- conf/app.ini | 2 ++ conf/locale/locale_en-US.ini | 1 + gogs.go | 2 +- models/webhook.go | 14 ++++++++------ modules/cron/manager.go | 2 +- modules/setting/setting.go | 13 +++++++++---- routers/admin/admin.go | 5 +---- templates/.VERSION | 2 +- templates/admin/config.tmpl | 6 ++++-- 9 files changed, 28 insertions(+), 19 deletions(-) (limited to 'modules') diff --git a/conf/app.ini b/conf/app.ini index 782dc51c..e80d77a9 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -89,6 +89,8 @@ ENABLE_REVERSE_PROXY_AUTO_REGISTERATION = false TASK_INTERVAL = 1 ; Deliver timeout in seconds DELIVER_TIMEOUT = 5 +; Allow insecure certification +ALLOW_INSECURE_CERTIFICATION = false [mailer] ENABLED = false diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 8ea383f2..9e691171 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -647,6 +647,7 @@ config.reset_password_code_lives = Reset Password Code Lives config.webhook_config = Webhook Configuration config.task_interval = Task Interval config.deliver_timeout = Deliver Timeout +config.allow_insecure_certification = Allow Insecure Certification config.mailer_config = Mailer Configuration config.mailer_enabled = Enabled config.mailer_name = Name diff --git a/gogs.go b/gogs.go index 09903917..b2f45b33 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.13.0209 Beta" +const APP_VER = "0.5.13.0210 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/webhook.go b/models/webhook.go index 8e112ac5..34349bb5 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -5,6 +5,7 @@ package models import ( + "crypto/tls" "encoding/json" "errors" "io/ioutil" @@ -307,13 +308,14 @@ func DeliverHooks() { defer func() { isShooting = false }() tasks := make([]*HookTask, 0, 10) - timeout := time.Duration(setting.WebhookDeliverTimeout) * time.Second + timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second x.Where("is_delivered=?", false).Iterate(new(HookTask), func(idx int, bean interface{}) error { t := bean.(*HookTask) req := httplib.Post(t.Url).SetTimeout(timeout, timeout). Header("X-Gogs-Delivery", t.Uuid). - Header("X-Gogs-Event", string(t.EventType)) + Header("X-Gogs-Event", string(t.EventType)). + SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.AllowInsecureCertification}) switch t.ContentType { case JSON: @@ -329,7 +331,7 @@ func DeliverHooks() { case GOGS: { if _, err := req.Response(); err != nil { - log.Error(4, "Delivery: %v", err) + log.Error(5, "Delivery: %v", err) } else { t.IsSucceed = true } @@ -337,15 +339,15 @@ func DeliverHooks() { case SLACK: { if res, err := req.Response(); err != nil { - log.Error(4, "Delivery: %v", err) + log.Error(5, "Delivery: %v", err) } else { defer res.Body.Close() contents, err := ioutil.ReadAll(res.Body) if err != nil { - log.Error(4, "%s", err) + log.Error(5, "%s", err) } else { if string(contents) != "ok" { - log.Error(4, "slack failed with: %s", string(contents)) + log.Error(5, "slack failed with: %s", string(contents)) } else { t.IsSucceed = true } diff --git a/modules/cron/manager.go b/modules/cron/manager.go index 135fec4f..2990ab06 100644 --- a/modules/cron/manager.go +++ b/modules/cron/manager.go @@ -15,7 +15,7 @@ var c = New() func NewCronContext() { c.AddFunc("Update mirrors", "@every 1h", models.MirrorUpdate) - c.AddFunc("Deliver hooks", fmt.Sprintf("@every %dm", setting.WebhookTaskInterval), models.DeliverHooks) + c.AddFunc("Deliver hooks", fmt.Sprintf("@every %dm", setting.Webhook.TaskInterval), models.DeliverHooks) if setting.Git.Fsck.Enable { c.AddFunc("Repository health check", fmt.Sprintf("@every %dh", setting.Git.Fsck.Interval), models.GitFsck) } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 55e0a79a..d71a8cda 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -68,8 +68,11 @@ var ( ReverseProxyAuthUser string // Webhook settings. - WebhookTaskInterval int - WebhookDeliverTimeout int + Webhook struct { + TaskInterval int + DeliverTimeout int + AllowInsecureCertification bool + } // Repository settings. RepoRootPath string @@ -508,8 +511,10 @@ func newNotifyMailService() { } func newWebhookService() { - WebhookTaskInterval = Cfg.Section("webhook").Key("TASK_INTERVAL").MustInt(1) - WebhookDeliverTimeout = Cfg.Section("webhook").Key("DELIVER_TIMEOUT").MustInt(5) + sec := Cfg.Section("webhook") + Webhook.TaskInterval = sec.Key("TASK_INTERVAL").MustInt(1) + Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) + Webhook.AllowInsecureCertification = sec.Key("ALLOW_INSECURE_CERTIFICATION").MustBool() } func NewServices() { diff --git a/routers/admin/admin.go b/routers/admin/admin.go index d54bb629..316f1d42 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -188,11 +188,8 @@ func Config(ctx *middleware.Context) { ctx.Data["ReverseProxyAuthUser"] = setting.ReverseProxyAuthUser ctx.Data["Service"] = setting.Service - ctx.Data["DbCfg"] = models.DbCfg - - ctx.Data["WebhookTaskInterval"] = setting.WebhookTaskInterval - ctx.Data["WebhookDeliverTimeout"] = setting.WebhookDeliverTimeout + ctx.Data["Webhook"] = setting.Webhook ctx.Data["MailerEnabled"] = false if setting.MailService != nil { diff --git a/templates/.VERSION b/templates/.VERSION index 1f077fbf..8f04f6d0 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.13.0209 Beta \ No newline at end of file +0.5.13.0210 Beta \ No newline at end of file diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index f8b4be0b..5cf84beb 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -102,9 +102,11 @@
{{.i18n.Tr "admin.config.task_interval"}}
-
{{.WebhookTaskInterval}} {{.i18n.Tr "tool.raw_minutes"}}
+
{{.Webhook.TaskInterval}} {{.i18n.Tr "tool.raw_minutes"}}
{{.i18n.Tr "admin.config.deliver_timeout"}}
-
{{.WebhookDeliverTimeout}} {{.i18n.Tr "tool.raw_seconds"}}
+
{{.Webhook.DeliverTimeout}} {{.i18n.Tr "tool.raw_seconds"}}
+
{{.i18n.Tr "admin.config.allow_insecure_certification"}}
+
-- cgit v1.2.3 From 28580aee63997e04c9b8136a7a189966b8f6b666 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 10 Feb 2015 22:53:46 -0500 Subject: modules/middleware/auth.go: remove uncheck login for watch a repo #929 --- modules/middleware/auth.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'modules') diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index b0bcd87f..3c06c69f 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -6,7 +6,6 @@ package middleware import ( "net/url" - "strings" "github.com/Unknwon/macaron" "github.com/macaron-contrib/csrf" @@ -50,10 +49,6 @@ func Toggle(options *ToggleOptions) macaron.Handler { if options.SignInRequire { if !ctx.IsSigned { - // Ignore watch repository operation. - if strings.HasSuffix(ctx.Req.RequestURI, "watch") { - return - } ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl) ctx.Redirect(setting.AppSubUrl + "/user/login") return -- cgit v1.2.3 From d02e45f985ce371eb33fcca86bf80ca078be1d88 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 11 Feb 2015 12:04:01 -0500 Subject: better naming on #891 --- conf/app.ini | 2 +- conf/locale/locale_en-US.ini | 2 +- gogs.go | 2 +- models/webhook.go | 2 +- modules/setting/setting.go | 8 ++++---- templates/.VERSION | 2 +- templates/admin/config.tmpl | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/conf/app.ini b/conf/app.ini index e80d77a9..2019557b 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -90,7 +90,7 @@ TASK_INTERVAL = 1 ; Deliver timeout in seconds DELIVER_TIMEOUT = 5 ; Allow insecure certification -ALLOW_INSECURE_CERTIFICATION = false +SKIP_TLS_VERIFY = false [mailer] ENABLED = false diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 9e691171..6b59be73 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -647,7 +647,7 @@ config.reset_password_code_lives = Reset Password Code Lives config.webhook_config = Webhook Configuration config.task_interval = Task Interval config.deliver_timeout = Deliver Timeout -config.allow_insecure_certification = Allow Insecure Certification +config.skip_tls_verify = Skip TLS Verify config.mailer_config = Mailer Configuration config.mailer_enabled = Enabled config.mailer_name = Name diff --git a/gogs.go b/gogs.go index b2f45b33..eac59362 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.13.0210 Beta" +const APP_VER = "0.5.13.0211 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/webhook.go b/models/webhook.go index 34349bb5..96af0b69 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -315,7 +315,7 @@ func DeliverHooks() { req := httplib.Post(t.Url).SetTimeout(timeout, timeout). Header("X-Gogs-Delivery", t.Uuid). Header("X-Gogs-Event", string(t.EventType)). - SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.AllowInsecureCertification}) + SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify}) switch t.ContentType { case JSON: diff --git a/modules/setting/setting.go b/modules/setting/setting.go index d71a8cda..6664c419 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -69,9 +69,9 @@ var ( // Webhook settings. Webhook struct { - TaskInterval int - DeliverTimeout int - AllowInsecureCertification bool + TaskInterval int + DeliverTimeout int + SkipTLSVerify bool } // Repository settings. @@ -514,7 +514,7 @@ func newWebhookService() { sec := Cfg.Section("webhook") Webhook.TaskInterval = sec.Key("TASK_INTERVAL").MustInt(1) Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) - Webhook.AllowInsecureCertification = sec.Key("ALLOW_INSECURE_CERTIFICATION").MustBool() + Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() } func NewServices() { diff --git a/templates/.VERSION b/templates/.VERSION index 8f04f6d0..2aad3653 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.13.0210 Beta \ No newline at end of file +0.5.13.0211 Beta \ No newline at end of file diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 5cf84beb..6c328353 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -105,8 +105,8 @@
{{.Webhook.TaskInterval}} {{.i18n.Tr "tool.raw_minutes"}}
{{.i18n.Tr "admin.config.deliver_timeout"}}
{{.Webhook.DeliverTimeout}} {{.i18n.Tr "tool.raw_seconds"}}
-
{{.i18n.Tr "admin.config.allow_insecure_certification"}}
-
+
{{.i18n.Tr "admin.config.skip_tls_verify"}}
+
-- cgit v1.2.3