Browse Source

install: validate SMTP From

Invalid SMTP From will cause fatal error in post-install and exit
the program.
pull/4116/head
Unknwon 8 years ago
parent
commit
5791e1398c
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 1
      conf/locale/locale_en-US.ini
  2. 2
      gogs.go
  3. 4
      modules/bindata/bindata.go
  4. 10
      routers/install.go
  5. 2
      templates/.VERSION

1
conf/locale/locale_en-US.ini

@ -116,6 +116,7 @@ sqlite3_not_available = Your release version does not support SQLite3, please do
invalid_db_setting = Database setting is not correct: %v invalid_db_setting = Database setting is not correct: %v
invalid_repo_path = Repository root path is invalid: %v invalid_repo_path = Repository root path is invalid: %v
run_user_not_match = Run user isn't the current user: %s -> %s run_user_not_match = Run user isn't the current user: %s -> %s
invalid_smtp_from = SMTP From field is not valid: %v
save_config_failed = Fail to save configuration: %v save_config_failed = Fail to save configuration: %v
invalid_admin_setting = Admin account setting is invalid: %v invalid_admin_setting = Admin account setting is invalid: %v
install_success = Welcome! We're glad that you chose Gogs, have fun and take care. install_success = Welcome! We're glad that you chose Gogs, have fun and take care.

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.140.0210" const APP_VER = "0.9.141.0211"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

10
routers/install.go

@ -6,6 +6,7 @@ package routers
import ( import (
"errors" "errors"
"net/mail"
"os" "os"
"os/exec" "os/exec"
"path" "path"
@ -247,6 +248,15 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
return return
} }
// Make sure FROM field is valid
_, err := mail.ParseAddress(form.SMTPFrom)
if err != nil {
ctx.Data["Err_SMTP"] = true
ctx.Data["Err_SMTPFrom"] = true
ctx.RenderWithErr(ctx.Tr("install.invalid_smtp_from", err), INSTALL, &form)
return
}
// Check logic loophole between disable self-registration and no admin account. // Check logic loophole between disable self-registration and no admin account.
if form.DisableRegistration && len(form.AdminName) == 0 { if form.DisableRegistration && len(form.AdminName) == 0 {
ctx.Data["Err_Services"] = true ctx.Data["Err_Services"] = true

2
templates/.VERSION

@ -1 +1 @@
0.9.140.0210 0.9.141.0211
Loading…
Cancel
Save