Fix quoted-printable encoding of e-mail addresses
When the RFC2047-style escapes are used for e-mail headers, only a
limited subset of characters is allowed to be passed unescaped. This is
governed by the "phrase" production in RFC 2047, section 5, case (3),
see [1].
In real world, this manifested as silently truncating the "(Code Review)"
part of the e-mail address when the author's name was not pure ASCII
(/me waves). Both of the two most popular open source IMAP servers,
Dovecot and Cyrus, interpret these Gerrit e-mails as having a
RFC5322-style comment, and therefore that part effectively gets lost.
GMail, on the other hand, shows this comment as a part of the From
address.
The change involved some refactoring of the way quoted-printable encoder
works. Working on Unicode code points one at a time is easier in this
context. It would be cool to delegate this altogether to some real
library, but org.apache.commons.codec.net.QuotedPrintableCodec doesn't
solve anything (it doesn't even bother to pretend that it talks
RFC2047), and I don't think I could get away with introducing JavaMail
as a dependency in a patch release.
[1] https://tools.ietf.org/html/rfc2047#section-5
Change-Id: I77452728f9b55a16bc9bd65208c187c44ce43153
2 files changed