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

kevinburke opened this issue Oct 6, 2017 · 2 comments


Copy link

@kevinburke kevinburke commented Oct 6, 2017

I expect that mail.ParseAddress(" <>") will parse to

    Name: "",
    Address: "",

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 <>

(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.

Copy link

@ianlancetaylor ianlancetaylor commented Oct 6, 2017

According to RFC 5322, given a string like "", the first "" 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.

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.
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.