Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/mail: ParseAddress may be incorrectly flagging valid values as errors #22161

Closed
kevinburke opened this issue Oct 6, 2017 · 2 comments
Closed

Comments

@kevinburke
Copy link
Contributor

@kevinburke kevinburke commented Oct 6, 2017

I expect that mail.ParseAddress("kev@inburke.com <kev@inburke.com>") will parse to

&mail.Address{
    Name: "kev@inburke.com",
    Address: "kev@inburke.com",
}

It's weird, granted, but I am guessing that the RFC for email parsing allows email-like things to be present in the Name field?

Noticed when using maintner to parse Gerrit emails. I also found this one:

Author: Author: Kevin Burke <kev@inburke.com>

(actual person's name withheld) which choked on the second Author: call.

It seems like it would be good to have a tool to validate the commit name/email before merge.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 6, 2017

According to RFC 5322, given a string like "kev@inburke.com kev@inburke.com", the first "kev@inburke.com" can only be parsed as a display-name. An unquoted display-name can only contain what RFC 5322 calls "atoms", which can be alphanumeric characters or various special characters, but the list of special characters does not include '@'. So I think that is not a valid address specification, and mail.ParseAddress is correct to reject it.

Similarly ':' is not permitted so I think your second string is also correctly rejected.

@kevinburke
Copy link
Contributor Author

@kevinburke kevinburke commented Oct 6, 2017

Gah, ignore me.

@kevinburke kevinburke closed this Oct 6, 2017
@golang golang locked and limited conversation to collaborators Oct 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.