From f4678e04aadb387204dd98ac55fa57ad31822677 Mon Sep 17 00:00:00 2001 From: Jake Nelson Date: Mon, 12 Jun 2023 03:09:58 +0000 Subject: [PATCH] Mark display names with special characters as needs_quoting Use the updated defitions for atom/phrase in RFC 5322 3.2.3 to --- lib/message/mu-contact.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/message/mu-contact.cc b/lib/message/mu-contact.cc index 0c25b5bc..e15d9355 100644 --- a/lib/message/mu-contact.cc +++ b/lib/message/mu-contact.cc @@ -29,17 +29,16 @@ using namespace Mu; -const std::string rfc822SpecialCharacters = "()<>@,;:\\\".[]"; +const std::string rfc5322SpecialCharacters = "()<>@,;:\\\"[]"; std::string Contact::display_name() const { auto needs_quoting= [](const std::string& n) { for (auto& c: n){ - // RFC 822 3.3 and RFC 5322 3.2.3 defines special characters, Ascii - // Control (CTL) characters (0-31), DEL (127), and space as requiring - // quoting. - if (c <=31 || c >= 127 || c == ' ' || rfc822SpecialCharacters.find(c) != std::string::npos){ + // RFC 5322 3.2.3 defines special characters, Ascii Control + // (CTL) characters (0-31), DEL (127) as requiring quoting. + if ((c >= 0 && c <=31) || c == 127 || rfc5322SpecialCharacters.find(c) != std::string::npos){ return true; } }