]> Cypherpunks repositories - gostls13.git/commit
net/mail: treat comment in address as display name
authorMichael Stapelberg <stapelberg@google.com>
Tue, 14 Nov 2017 12:46:03 +0000 (04:46 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 14 Nov 2017 22:07:08 +0000 (22:07 +0000)
commitfcee1897767c0cfa6e13a843fe5ee5d1deb8081b
treeee58caad48c0ca197a30f13851656afd517d4386
parent01c979dabef2c8edb3fffd99e1f89781b4d2c159
net/mail: treat comment in address as display name

I verified this change on a corpus of > 200 GB of emails since the mid-90s. With
this change, more addresses parse than before, and anything which parsed before
still parses.

In said corpus, I came across the edge case of comments preceding an
addr-spec (with angle brackets!), e.g. “(John Doe) <john@example.com>”, which
does not satisfy the conditions to be treated as a fallback, as per my reading
of RFC2822.

This change does not parse quoted-strings within comments (a corresponding TODO
is in the code), but I have not seen that in the wild.

Fixes #22670

Change-Id: I526fcf7c6390aa1c219fdec1852f26c514506f76
Reviewed-on: https://go-review.googlesource.com/77474
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/mail/message.go
src/net/mail/message_test.go