Don't MIME-encode RFC822 mailbox local parts
This is explicilty disallowed by RFC 2074 §5 and not accepted by mail servers. See #336
This commit is contained in:
parent
c306c2c5fa
commit
534b4e27d9
2 changed files with 16 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue