Correctly handle escaping UTF-8 characters in RFC822 mailboxes

Use string.get_next_char() to handle iterating over an
RFC822.MailboxAddress mailbox local part, and explicitly allow UTF-8
2, 3, and 4 byte chars without quoting, per RFC 5322.

This lets us fix the test cases that use UTF-8 chars in the local part.
This commit is contained in:
Michael Gratton 2019-04-24 20:38:11 +10:00
parent c58d0b74e9
commit c306c2c5fa
2 changed files with 25 additions and 10 deletions

View file

@ -228,6 +228,7 @@ class Geary.RFC822.MailboxAddressTest : TestCase {
// "\"test\" test\"@example.com");
//assert(new MailboxAddress(null, "test\"test@example.com").to_rfc822_address() ==
// "\"test\"test\"@example.com");
assert_string(
"$test@example.com",
new MailboxAddress(null, "$test@example.com").to_rfc822_address()
@ -236,14 +237,19 @@ class Geary.RFC822.MailboxAddressTest : TestCase {
"\"test@test\"@example.com",
new MailboxAddress(null, "test@test@example.com").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
assert_string(
"=?iso-8859-1?b?qQ==?=@example.com",
"©@example.com",
new MailboxAddress(null, "©@example.com").to_rfc822_address()
);
assert_string(
"=?UTF-8?b?8J+YuA==?=@example.com",
"😸@example.com",
new MailboxAddress(null, "😸@example.com").to_rfc822_address()
);
}
public void to_rfc822_string() throws Error {