]> Cypherpunks repositories - gostls13.git/commit
net/mail: enhanced Address.String and ParseAddress to match RFC 5322
authorMathiasB <git@denbeke.be>
Fri, 10 Apr 2015 10:14:16 +0000 (12:14 +0200)
committerRuss Cox <rsc@golang.org>
Wed, 22 Jul 2015 20:36:46 +0000 (20:36 +0000)
commitdaaa45073e887cb6d8075c2caafdfe8425bca25a
tree04e26ddf5671cf0438753468d52b6a69c4453e92
parent5201bf7ad184cac07466016a78b80aed5e472be4
net/mail: enhanced Address.String and ParseAddress to match RFC 5322

Updated Address.String so it restores quoted local parts, which wasn't
done before.
When parsing `<" "@example.com>`, the formatted string returned
`< @example>`, which doens't match RFC 5322, since a space is not atext.
Another example is `<"bob@valid"@example.com>` which returned
`<bob@valid@example.com>`, which is completely invalid.
I also added support for quotes and backslashes in a quoted local part.

Besides formatting a parsed Address, the ParseAddress function also
needed more testing and finetuning for special cases.
Things like `<.john.doe@example.com>` and `<john..doe@example.com>`
e.a. were accepted, but are invalid.
I fixed those details and add tests for some other special cases.

Fixes #10768

Change-Id: Ib0caf8ad603eb21e32fcb957a5f1a0fe5d1c6e6e
Reviewed-on: https://go-review.googlesource.com/8724
Reviewed-by: Russ Cox <rsc@golang.org>
src/net/mail/message.go
src/net/mail/message_test.go