Skip to content

Commit

Permalink
Update smtpd.go: Adding case-insensitive flags to regex'es
Browse files Browse the repository at this point in the history
The syntax is taken from https://stackoverflow.com/a/15326471/1668200
Do you have tests for case-insensitivity?
  • Loading branch information
ThomasLandauer authored Dec 14, 2024
1 parent 13027bf commit 7ccd8e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/smtpd/smtpd.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]: ?<([^<>\v]+)>( |$)(.*)?`)
mailFromRE = regexp.MustCompile(`[Ff][Rr][Oo][Mm]: ?<(|[^<>\v]+)>( |$)(.*)?`) // Delivery Status Notifications are sent with "MAIL FROM:<>"
rcptToRE = regexp.MustCompile(`(?i)TO: ?<([^<>\v]+)>( |$)(.*)?`)
mailFromRE = regexp.MustCompile(`(?i)FROM: ?<(|[^<>\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 7ccd8e2

Please sign in to comment.