diff --git a/src/engine/rfc822/rfc822-mailbox-address.vala b/src/engine/rfc822/rfc822-mailbox-address.vala index eda28fe1..5ead3307 100644 --- a/src/engine/rfc822/rfc822-mailbox-address.vala +++ b/src/engine/rfc822/rfc822-mailbox-address.vala @@ -445,12 +445,14 @@ public class Geary.RFC822.MailboxAddress : * brackets. */ public string to_rfc822_address() { - // XXX GMime.utils_header_encode_text won't quote if spaces or - // quotes present, and GMime.utils_quote_string will - // erroneously quote if a '.' is present (which at least - // Yahoo doesn't like in SMTP return paths), so need to quote + // GMime.utils_header_encode_text won't quote if spaces or + // quotes present, GMime.utils_quote_string will erroneously + // quote if a '.' is present (which at least Yahoo doesn't + // like in SMTP return paths), and + // GMime.utils_header_encode_text will use MIME encoding, + // which is disallowed in mailboxes by RFC 2074 §5. So quote // manually. - string local_part = GMime.utils_header_encode_text(this.mailbox); + string local_part = this.mailbox; if (local_part_needs_quoting(local_part)) { local_part = quote_string(local_part); } diff --git a/test/engine/rfc822-mailbox-address-test.vala b/test/engine/rfc822-mailbox-address-test.vala index d65a5869..9aa2b9e7 100644 --- a/test/engine/rfc822-mailbox-address-test.vala +++ b/test/engine/rfc822-mailbox-address-test.vala @@ -238,6 +238,15 @@ class Geary.RFC822.MailboxAddressTest : TestCase { new MailboxAddress(null, "test@test@example.com").to_rfc822_address() ); + // RFC 2047 reserved words in the local-part must be used + // as-is, and in particular not encoded per that RFC. See RFC + // 2047 §5 and GNOME/geary#336 + string RFC_2074 = "libc-alpha-sc.1553427554.ndgdflaalknmibgfkpak-hi-angel=yandex.ru@sourceware.org"; + assert_string( + RFC_2074, + new MailboxAddress(null, RFC_2074).to_rfc822_address() + ); + // Likewise, Unicode chars should be passed through. Note that // these can only be sent if a UTF8 connection is negotiated // with the SMTP server