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: unclear error message #21018

Closed
kevinburke opened this issue Jul 15, 2017 · 11 comments
Closed

net/mail: ParseAddress: unclear error message #21018

kevinburke opened this issue Jul 15, 2017 · 11 comments

Comments

@kevinburke
Copy link
Contributor

@kevinburke kevinburke commented Jul 15, 2017

When parsing this address:

mail.ParseAddress("Foo (middle) Bar <foo@example.com>")

you get the following error:

mail: no angle-addr

That's confusing because an angle-addr is present in the input.

The email address should be formatted with quotes as:

mail.ParseAddress(`"Foo (middle) Bar" <foo@example.com>`)

But we could probably be clearer about the error there.

@kevinburke kevinburke changed the title net/mail: unclear error message net/mail: ParseAddress: unclear error message Jul 15, 2017
@bradfitz bradfitz added the NeedsFix label Jul 15, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Jul 15, 2017
@xmudrii
Copy link
Contributor

@xmudrii xmudrii commented Jul 15, 2017

Errors seems quite easy to fix. I would like to give it a try, but before, does somebody want to comment on the format.

Should we show how it should be, such as:

incorrect address format, expected `"Foo (middle) Bar" <foo@example.com>`

or just drop a more precise message about error:

incorrect address format

/cc @kevinburke @bradfitz

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 15, 2017

I think neither option is quite right here. It would be best if we could say that the error with the example is a missing quote.

@xmudrii
Copy link
Contributor

@xmudrii xmudrii commented Jul 15, 2017

@ianlancetaylor i'll try to write some code and push cl, if tests pass, you can expect it.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 15, 2017

CL https://golang.org/cl/48990 mentions this issue.

@xmudrii
Copy link
Contributor

@xmudrii xmudrii commented Jul 15, 2017

@ianlancetaylor I hope you've thought about something like this one

@xmudrii
Copy link
Contributor

@xmudrii xmudrii commented Jul 16, 2017

If anybody wants to take on this, feel free to do. Sorry, I'm out of time for next few days.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 17, 2017

CL https://golang.org/cl/49410 mentions this issue.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 24, 2017

CL https://golang.org/cl/50911 mentions this issue.

@guilhermebr
Copy link
Contributor

@guilhermebr guilhermebr commented Jul 24, 2017

Calling parseAddres for:
Foo middle Bar <foo@example.com> returns
"Foo middle Bar" <foo@example.com>

and:
"Foo (middle) Bar" <foo@example.com> returns
"Foo (middle) Bar" <foo@example.com>

so I made a change that calling for:
Foo (middle) Bar <foo@example.com> returns
"Foo (middle) Bar" <foo@example.com>
instead of error

gopherbot pushed a commit that referenced this issue Aug 29, 2017
Updates #21018

Change-Id: I00b6667fb5fee78559a391815f58760a2baea90e
Reviewed-on: https://go-review.googlesource.com/50911
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@burakguven
Copy link
Contributor

@burakguven burakguven commented Oct 24, 2017

Should this be closed? Since @guilhermebr's change the example given in OP no longer returns an error.

@mvdan
Copy link
Member

@mvdan mvdan commented Nov 8, 2017

Sounds like it to me. If anyone disagrees or has any other examples to be fixed, feel free to reopen or open a new issue.

@mvdan mvdan closed this Nov 8, 2017
@golang golang locked and limited conversation to collaborators Nov 8, 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
8 participants
You can’t perform that action at this time.