diff options
author | Carlos Felgueiras <carlosfelgueiras@tecnico.ulisboa.pt> | 2024-02-24 00:02:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 23:02:14 +0000 |
commit | 6f6120dfa8d549d0b866eeb9317054fea831c844 (patch) | |
tree | c53e23d8ea5c87e5f01ca6210bdd4ce216cc010c /routers/install/install.go | |
parent | 08c1926e1c3e2487f207b5f225d8b0f2831d0708 (diff) | |
download | gitea-6f6120dfa8d549d0b866eeb9317054fea831c844.tar.gz gitea-6f6120dfa8d549d0b866eeb9317054fea831c844.zip |
Fix validity of the FROM email address not being checked (#29347)
Fixes #27188.
Introduces a check on the installation that tries to parse the FROM
address. If it fails, shows a new error message to the user.
---------
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'routers/install/install.go')
-rw-r--r-- | routers/install/install.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/install/install.go b/routers/install/install.go index 78372669f4..decf74cecb 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -7,6 +7,7 @@ package install import ( "fmt" "net/http" + "net/mail" "os" "os/exec" "path/filepath" @@ -419,6 +420,11 @@ func SubmitInstall(ctx *context.Context) { } if len(strings.TrimSpace(form.SMTPAddr)) > 0 { + if _, err := mail.ParseAddress(form.SMTPFrom); err != nil { + ctx.RenderWithErr(ctx.Tr("install.smtp_from_invalid"), tplInstall, &form) + return + } + cfg.Section("mailer").Key("ENABLED").SetValue("true") cfg.Section("mailer").Key("SMTP_ADDR").SetValue(form.SMTPAddr) cfg.Section("mailer").Key("SMTP_PORT").SetValue(form.SMTPPort) |