summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-06-04 00:48:49 +0700
committerShulhan <ms@kilabit.info>2023-06-04 01:01:01 +0700
commitd4f61ca057f3b786835b403546eaab31987f368f (patch)
tree3f325fb96da789206909fe3a1be6d0913b9d2eae
parent1ed486753c30ca8e9ab7380e90c117d533bc2dae (diff)
downloadpakakeh.go-d4f61ca057f3b786835b403546eaab31987f368f.tar.xz
lib/email: remove spaces when parsing domain in parseMailbox
In obsolete syntax for mailbox in Field value, a domain can have space. For example, the following message-id is valid according to RFC 5322 Section A.6.3: message-id:<1234 @ local(blah) .machine .example>\r\n This changes handle this by removing all spaces before validating the domain name.
-rw-r--r--lib/email/mailbox.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/email/mailbox.go b/lib/email/mailbox.go
index 3460c71d..efd5b3af 100644
--- a/lib/email/mailbox.go
+++ b/lib/email/mailbox.go
@@ -214,6 +214,9 @@ func parseMailbox(mbox *Mailbox, parser *libbytes.Parser, prevd byte) (c byte, e
}
domain:
if len(value) != 0 {
+ // Remove all spaces between characters to handle obsolete
+ // domain value, for example "domain . tld" are valid.
+ value = libbytes.RemoveSpaces(value)
if !libnet.IsHostnameValid(value, false) {
return c, fmt.Errorf(`%s: invalid domain '%s'`, logp, value)
}