Skip to content

Commit

Permalink
Chore: Stricter SMTP 'MAIL FROM' & 'RCPT TO' handling (#409)
Browse files Browse the repository at this point in the history
* Update lib.go: Changing `mailFromRE` and `rcptToRE` regex

I don't know how to rebase so I started from scratch ;-)

2 changes compared to what you said at #406 (comment)
* I did the same for `rcptToRE`
* I replaced the `*` quantifier with `+`, for consistency

* Update lib.go

* Allow valid empty MAIL FROM value

---------

Co-authored-by: Ralph Slooten <[email protected]>
  • Loading branch information
ThomasLandauer and axllent authored Dec 14, 2024
1 parent 0af5d18 commit 2ea92d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/smtpd/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
var (
// Debug `true` enables verbose logging.
Debug = false
rcptToRE = regexp.MustCompile(`[Tt][Oo]:\s?<(.+)>`)
mailFromRE = regexp.MustCompile(`[Ff][Rr][Oo][Mm]:\s?<(.*)>(\s(.*))?`) // Delivery Status Notifications are sent with "MAIL FROM:<>"
rcptToRE = regexp.MustCompile(`[Tt][Oo]: ?<([^<>\v]+)>( |$)(.*)?`)
mailFromRE = regexp.MustCompile(`[Ff][Rr][Oo][Mm]: ?<(|[^<>\v]+)>( |$)(.*)?`) // Delivery Status Notifications are sent with "MAIL FROM:<>"

// extract mail size from 'MAIL FROM' parameter
mailFromSizeRE = regexp.MustCompile(`(?U)(^| |,)[Ss][Ii][Zz][Ee]=(.*)($|,| )`)
Expand Down

0 comments on commit 2ea92d1

Please sign in to comment.