go
go copied to clipboard
net/mail: ParseAddress does not allow mixed quoted / unquoted local parts
What version of Go are you using (go version)?
I'm not sure how to get this information from play.golang.org.
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
I'm not sure how to get this information from play.golang.org.
What did you do?
package main
import (
"fmt"
"net/mail"
)
func main() {
input := `foo."x"[email protected]`
fmt.Println(mail.ParseAddress(input))
}
https://play.golang.org/p/OjrtE1S12lP
What did you expect to see?
<[email protected]> <nil>
What did you see instead?
<nil> mail: no angle-addr
Section 3.2.3 suggests that the local part of an address may be a dot-atom or a quoted string, but not a combination of both as your example shows. Do mail clients accept this address?
There is also section 4.4 describing obs-local-part = word *("." word) so that email address should be valid. Also mail send like
$ sendmail -t
From: [email protected]
To: foo."x"[email protected]
Subject: Test
Test.
does arrive.
Note: While section 4 is obsolete, it must be accepted.
Though these syntactic forms MUST NOT be generated according to the grammar in section 3, they MUST be accepted and parsed by a conformant receiver.
I read “.” as one literal period character
Well yeah, so the obs-local-part in foo."x".bar should be evaluated like atom "." quoted-string "." atom, which looks valid based on:
obs-local-part = word *("." word)
word = atom / quoted-string
Am I reading the RFC wrong?
Tbh I’m not sure. What’s your use case? Do you have a need to accept this form of address?
I've tried to put list of valid email addresses [0] through our email validation and some did not pass. So it seemed reasonable to open a bug report about this. If full RFC 5322 compatibility is not a desired goal, then this can be closed.
[0] https://github.com/StoneCypher/testdata-valid-email/blob/master/testdata-valid-email.js