diff options
author | Carlos Felgueiras <carlosfelgueiras@tecnico.ulisboa.pt> | 2024-02-24 00:02:14 +0100 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-02-26 22:30:26 +0100 |
commit | fc384e494eae0264bf1c00c91567cacadd3ace8d (patch) | |
tree | 6fd2320635b27a1254fb0210c7eb70b3752c5878 /routers/install | |
parent | Refactor generate-svg.js (#29348) (diff) | |
download | forgejo-fc384e494eae0264bf1c00c91567cacadd3ace8d.tar.xz forgejo-fc384e494eae0264bf1c00c91567cacadd3ace8d.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>
(cherry picked from commit 6f6120dfa8d549d0b866eeb9317054fea831c844)
Conflicts:
options/locale/locale_en-US.ini
context
Diffstat (limited to 'routers/install')
-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 48271a64f2..13504953ce 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" @@ -423,6 +424,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) |