mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-19 19:23:39 +09:00
fix(user): unify email validation for registration and settings (#39304)
Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
silverwind
wxiaoguang
parent
c6c671e113
commit
7ebb2caa9e
@@ -30,15 +30,10 @@ func (s *SendmailSender) Send(from string, to []string, msg io.WriterTo) error {
|
||||
envelopeFrom = setting.MailService.EnvelopeFrom
|
||||
}
|
||||
|
||||
args := []string{"-f", envelopeFrom, "-i"}
|
||||
// Use "-t" to extract recipients from message headers, don't add email addresses to the command line.
|
||||
// Because email address can start with "-" which can lead to injected command line argument (RCE)
|
||||
args := []string{"-f", envelopeFrom, "-i", "-t"}
|
||||
args = append(args, setting.MailService.SendmailArgs...)
|
||||
for _, recipient := range to {
|
||||
smtpTo, err := sanitizeEmailAddress(recipient)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid recipient address %q: %w", recipient, err)
|
||||
}
|
||||
args = append(args, smtpTo)
|
||||
}
|
||||
log.Trace("Sending with: %s %v", setting.MailService.SendmailPath, args)
|
||||
|
||||
desc := fmt.Sprintf("SendMail: %s %v", setting.MailService.SendmailPath, args)
|
||||
|
||||
Reference in New Issue
Block a user