diff options
author | Jan Engelhardt <[email protected]> | 2024-06-11 18:49:10 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-06-11 18:49:10 +0000 |
commit | beb238b5e7a8e50dd2937983e6d54ed79fdb5031 (patch) | |
tree | 9d82c7290324451295dd532c2064f1a663adc7b7 | |
parent | Fix a test failure in testNewFromString (#311) (diff) | |
download | vmime-beb238b5e7a8e50dd2937983e6d54ed79fdb5031.tar.gz vmime-beb238b5e7a8e50dd2937983e6d54ed79fdb5031.zip |
Fix a test failure in pathTest::testGenerate (#312)
* Fix a test failure in testNewFromString
Fixes an oversight in d296c2d1.
* Fix a test failure in pathTest::testGenerate
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.
-rw-r--r-- | src/vmime/emailAddress.cpp | 39 | ||||
-rw-r--r-- | 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 <vmime::word>(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::word>("@", vmime::charsets::US_ASCII)); - txt.appendWord(make_shared <vmime::word>(m_domainName)); - } + txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII)); + txt.appendWord(make_shared <vmime::word>(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 << ">"; |