From f4c611b736ac290ec4f99faaa48b59fdd7c63809 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 9 Dec 2020 16:58:57 +0100 Subject: 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.) --- src/vmime/mailbox.cpp | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/vmime/mailbox.cpp b/src/vmime/mailbox.cpp index db5cc74e..30a082ea 100644 --- a/src/vmime/mailbox.cpp +++ b/src/vmime/mailbox.cpp @@ -355,44 +355,14 @@ void mailbox::generateImpl( // - if it contains characters in a charset different from "US-ASCII", // - and/or if it contains one or more of these special chars: // CR LF TAB " ; , < > ( ) @ / ? . = : - + // these special chars only require quoting, not full encoding // Check whether there are words that are not "US-ASCII" // and/or contain the special chars. bool forceEncode = false; for (size_t w = 0 ; !forceEncode && w != m_name.getWordCount() ; ++w) { - if (m_name.getWordAt(w)->getCharset() == charset(charsets::US_ASCII)) { - - const string& buffer = m_name.getWordAt(w)->getBuffer(); - - for (string::const_iterator c = buffer.begin() ; - !forceEncode && c != buffer.end() ; ++c) { - - switch (*c) { - - case '\r': - case '\n': - case '\t': - case ';': - case ',': - case '<': case '>': - case '(': case ')': - case '@': - case '/': - case '?': - case '.': - case '=': - case ':': - case '"': - - forceEncode = true; - break; - } - } - - } else { - + if (m_name.getWordAt(w)->getCharset() != charset(charsets::US_ASCII)) { forceEncode = true; } } -- cgit v1.2.3