From 1237f7162939fffa982a1b2f5b6848be5f468e98 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 11 Jun 2024 13:32:16 +0200 Subject: [PATCH] Fix a test failure in pathTest::testGenerate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partially revert v0.9.2-183-g9b65b4de. As per RFC 5322 §3.4.1, an email address must always have a @. As per RFC 5321 §4.1.2, a path is similar to an email address (always @), with "" (<>) being the only other special value. Fixes #294, #301. --- src/vmime/emailAddress.cpp | 39 +++++++++++--------------------------- src/vmime/path.cpp | 10 ---------- 2 files changed, 11 insertions(+), 38 deletions(-) diff --git a/src/vmime/emailAddress.cpp b/src/vmime/emailAddress.cpp index ed17f555..e6873803 100644 --- a/src/vmime/emailAddress.cpp +++ b/src/vmime/emailAddress.cpp @@ -596,27 +596,15 @@ void emailAddress::generateImpl( } - if (!domainPart.empty()) { - os << localPart - << "@" - << domainPart; - - if (newLinePos) { - *newLinePos = curLinePos - + localPart.length() - + 1 // @ - + domainPart.length(); - } - } else { - // this should only be true if m_useMyHostname is false and an address without - // an `@` is encountered - - os << localPart; - - if (newLinePos) { - *newLinePos = curLinePos - + localPart.length(); - } + os << localPart + << "@" + << domainPart; + + if (newLinePos) { + *newLinePos = curLinePos + + localPart.length() + + 1 // @ + + domainPart.length(); } } @@ -710,13 +698,8 @@ const text emailAddress::toText() const { text txt; txt.appendWord(make_shared (m_localName)); - - if (!m_domainName.isEmpty()) { - // this should only be skipped if m_useMyHostname is false and an address without - // an `@` is encountered - txt.appendWord(make_shared ("@", vmime::charsets::US_ASCII)); - txt.appendWord(make_shared (m_domainName)); - } + txt.appendWord(make_shared ("@", vmime::charsets::US_ASCII)); + txt.appendWord(make_shared (m_domainName)); return txt; } diff --git a/src/vmime/path.cpp b/src/vmime/path.cpp index a3aaff21..a672b22c 100644 --- a/src/vmime/path.cpp +++ b/src/vmime/path.cpp @@ -192,16 +192,6 @@ void path::generateImpl( *newLinePos = curLinePos + 2; } - } else if (!m_localPart.empty() && m_domain.empty()) { - // this should only be true if m_useMyHostname is false and an address without - // an `@` is encountered - - os << "<" << m_localPart << ">"; - - if (newLinePos) { - *newLinePos = curLinePos + m_localPart.length() + 2; - } - } else { os << "<" << m_localPart << "@" << m_domain << ">";