add pedantic mode (used by localserve) that refuses some behaviour that is invalid according to specifications and that we normally accept for compatibility

This commit is contained in:
Mechiel Lukkien
2023-03-12 15:16:01 +01:00
parent 132f08913b
commit 317dc78397
16 changed files with 127 additions and 56 deletions

View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/mjl-/mox/dns"
"github.com/mjl-/mox/moxvar"
"github.com/mjl-/mox/smtp"
)
@ -325,8 +326,8 @@ func (p *parser) xlocalpart() smtp.Localpart {
s += "." + p.xatom(true)
}
}
// todo: have a strict parser that only allows the actual max of 64 bytes. some services have large localparts because of generated (bounce) addresses.
if len(s) > 128 {
// In the wild, some services use large localparts for generated (bounce) addresses.
if moxvar.Pedantic && len(s) > 64 || len(s) > 128 {
// ../rfc/5321:3486
p.xerrorf("localpart longer than 64 octets")
}