1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-01-14 02:33:13 +02:00

Add case-insensitive flags to regex'es (#411)

* Update smtpd.go: Adding case-insensitive flags to regex'es
* Update smtpd_test.go
This commit is contained in:
Thomas Landauer 2024-12-14 19:56:20 +01:00 committed by GitHub
parent 13027bf10b
commit 9f4908d11d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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]=(.*)($|,| )`)

View File

@ -84,8 +84,8 @@ func TestCmdHELO(t *testing.T) {
// Verify that HELO resets the current transaction state like RSET.
// RFC 2821 section 4.1.4 says EHLO should cause a reset, so verify that HELO does it too.
cmdCode(t, conn, "MAIL FROM:<sender@example.com>", "250")
cmdCode(t, conn, "RCPT TO:<recipient@example.com>", "250")
cmdCode(t, conn, "mail from:<sender@example.com>", "250") // Also testing case-insensitivity
cmdCode(t, conn, "rcpt to:<recipient@example.com>", "250")
cmdCode(t, conn, "HELO host.example.com", "250")
cmdCode(t, conn, "DATA", "503")