Sfoglia il codice sorgente

Fix validity of the FROM email address not being checked (#29347) (#29360)

Backport #29347 by @carlosfelgueiras

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: Carlos Felgueiras <carlosfelgueiras@tecnico.ulisboa.pt>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
tags/v1.21.7
Giteabot 2 mesi fa
parent
commit
35db5a373b
Nessun account collegato all'indirizzo email del committer
2 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 1
    0
      options/locale/locale_en-US.ini
  2. 6
    0
      routers/install/install.go

+ 1
- 0
options/locale/locale_en-US.ini Vedi File

@@ -246,6 +246,7 @@ email_title = Email Settings
smtp_addr = SMTP Host
smtp_port = SMTP Port
smtp_from = Send Email As
smtp_from_invalid = The "Send Email As" address is invalid
smtp_from_helper = Email address Gitea will use. Enter a plain email address or use the "Name" <email@example.com> format.
mailer_user = SMTP Username
mailer_password = SMTP Password

+ 6
- 0
routers/install/install.go Vedi File

@@ -7,6 +7,7 @@ package install
import (
"fmt"
"net/http"
"net/mail"
"os"
"os/exec"
"path/filepath"
@@ -417,6 +418,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)

Loading…
Annulla
Salva