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: Address.String() and ParseAddress() don't match RFC 5322 #10768

Closed
DenBeke opened this issue May 10, 2015 · 3 comments
Closed

net/mail: Address.String() and ParseAddress() don't match RFC 5322 #10768

DenBeke opened this issue May 10, 2015 · 3 comments
Assignees
Milestone

Comments

@DenBeke
Copy link
Contributor

@DenBeke DenBeke commented May 10, 2015

I have noticed that Address.String() and ParseAddress() functions don't match RFC 5322, especially regarding quoted-strings, and some other special cases.

Most simple way to find out if Address.String() and ParseAddress() do their job, is to look if a parsed and formatted mail address can be parsed again, which isn't the case: https://play.golang.org/p/Kl0FDI-BxO

package main

import "fmt"
import "net/mail"

func main() {
    a, _ := mail.ParseAddress(`" "@test.com`)
    fmt.Println(`" "@test.com`)
    fmt.Println(a)
    _, err := mail.ParseAddress(a.String())
    fmt.Println(err)

    fmt.Println()

    a, _ = mail.ParseAddress(`"hello@world"@test.com`)
    fmt.Println(`"hello@world"@test.com`)
    fmt.Println(a)
    _, err = mail.ParseAddress(a.String())
    fmt.Println(err)

}
" "@test.com
< @test.com>
mail: invalid string

"hello@world"@test.com
<hello@world@test.com>
mail: unclosed angle-addr

I fixed this problem, and wrote tests for other special cases: https://go-review.googlesource.com/#/c/8724/
I created this patch request a month ago, but hadn't got any answer unfortunately...

@bradfitz bradfitz added this to the Go1.5 milestone May 10, 2015
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented May 10, 2015

Sorry, this did slip through the cracks on assigning a reviewer. But you did mail this prior to the Go 1.5 freeze.

I sent out some initial comments, but I'll let @dsymonds handle finishing the review, since it's his code I believe.

@DenBeke
Copy link
Contributor Author

@DenBeke DenBeke commented May 10, 2015

Ok, thank you!

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 18, 2015

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

@rsc rsc closed this in daaa450 Jul 22, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
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
4 participants
You can’t perform that action at this time.