[geary/wip/336-smtp-rcpt-to-quoting: 2/3] Don't MIME-encode RFC822 mailbox local parts
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/336-smtp-rcpt-to-quoting: 2/3] Don't MIME-encode RFC822 mailbox local parts
- Date: Wed, 24 Apr 2019 10:48:23 +0000 (UTC)
commit 534b4e27d9be1556401daf3095ee155e1351850a
Author: Michael Gratton <mike vee net>
Date: Wed Apr 24 20:43:39 2019 +1000
Don't MIME-encode RFC822 mailbox local parts
This is explicilty disallowed by RFC 2074 §5 and not accepted by mail
servers.
See #336
src/engine/rfc822/rfc822-mailbox-address.vala | 12 +++++++-----
test/engine/rfc822-mailbox-address-test.vala | 9 +++++++++
2 files changed, 16 insertions(+), 5 deletions(-)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]