diff options
author | Jan Engelhardt <[email protected]> | 2020-12-09 15:58:57 +0000 |
---|---|---|
committer | Jan Engelhardt <[email protected]> | 2020-12-11 22:10:39 +0000 |
commit | f4c611b736ac290ec4f99faaa48b59fdd7c63809 (patch) | |
tree | 3b2a523a15513324175c40dec2dad1747c9dc0ef /tests/parser/mailboxTest.cpp | |
parent | Check for DSN extension support before using it. (diff) | |
download | vmime-f4c611b736ac290ec4f99faaa48b59fdd7c63809.tar.gz vmime-f4c611b736ac290ec4f99faaa48b59fdd7c63809.zip |
Avoid force-encoding display names that fit within qcontent
When the display name contains an At sign, or anything of the sort,
libvmime would forcibly encode this to =?...?=, even if the line
is fine ASCII which only needs quoting.
rspamd takes excessive quoting as a sign of spam and penalizes
such mails by raising the score (rule/match: TO_EXCESS_QP et al.)
Diffstat (limited to 'tests/parser/mailboxTest.cpp')
-rw-r--r-- | tests/parser/mailboxTest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp index 23d1b4ac..997a6a38 100644 --- a/tests/parser/mailboxTest.cpp +++ b/tests/parser/mailboxTest.cpp @@ -31,6 +31,7 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VMIME_TEST(testEmptyEmailAddress) VMIME_TEST(testSeparatorInComment) VMIME_TEST(testMalformations) + VMIME_TEST(testExcessiveQuoting) VMIME_TEST_LIST_END @@ -170,4 +171,17 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest) VASSERT_EQ("email", "[email protected]", mbox.getEmail()); } + void testExcessiveQuoting() { + using namespace vmime; + + // Check that ASCII display names are not encoded more than necessary + emailAddress e("[email protected]"); + auto a = make_shared<mailbox>(text(word("Foo B@r", charsets::US_ASCII)), e); + VASSERT_EQ("generate", "\"Foo B@r\" <[email protected]>", a->generate()); + VASSERT_NEQ("generate", "=?utf-8?Q?Foo_B=40r?= <[email protected]>", a->generate()); + + a = make_shared<mailbox>(text(word("Foo B@r", charsets::UTF_8)), e); + VASSERT_EQ("generate", "=?utf-8?Q?Foo_B=40r?= <[email protected]>", a->generate()); + } + VMIME_TEST_SUITE_END |