install: validate SMTP From

Invalid SMTP From will cause fatal error in post-install and exit
the program.
pull/4116/head
Unknwon 2017-02-11 03:29:30 -05:00
parent 9b72661767
commit 5791e1398c
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
5 changed files with 15 additions and 4 deletions

View File

@ -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_repo_path = Repository root path is invalid: %v
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
invalid_admin_setting = Admin account setting is invalid: %v
install_success = Welcome! We're glad that you chose Gogs, have fun and take care.

View File

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

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,7 @@ package routers
import (
"errors"
"net/mail"
"os"
"os/exec"
"path"
@ -247,6 +248,15 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
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.
if form.DisableRegistration && len(form.AdminName) == 0 {
ctx.Data["Err_Services"] = true

View File

@ -1 +1 @@
0.9.140.0210
0.9.141.0211