Skip to content

Commit

Permalink
Fix a test failure in pathTest::testGenerate
Browse files Browse the repository at this point in the history
Partially revert v0.9.2-183-g9b65b4de.

As per RFC 5322, an email address must always have a @.
As per RFC 5321, a path is like an email address (always @),
with "" (<>) being the only other special value.

Fixes kisli#294, kisli#301.
  • Loading branch information
jengelh committed Jun 11, 2024
1 parent bc3e555 commit 06371a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
39 changes: 11 additions & 28 deletions src/vmime/emailAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 0 additions & 10 deletions src/vmime/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 << ">";
Expand Down

0 comments on commit 06371a4

Please sign in to comment.