Skip to content

Commit beb238b

Browse files
authored
Fix a test failure in pathTest::testGenerate (#312)
* Fix a test failure in testNewFromString Fixes an oversight in d296c2d. * 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.
1 parent aa60d00 commit beb238b

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

src/vmime/emailAddress.cpp

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -596,27 +596,15 @@ void emailAddress::generateImpl(
596596
}
597597

598598

599-
if (!domainPart.empty()) {
600-
os << localPart
601-
<< "@"
602-
<< domainPart;
603-
604-
if (newLinePos) {
605-
*newLinePos = curLinePos
606-
+ localPart.length()
607-
+ 1 // @
608-
+ domainPart.length();
609-
}
610-
} else {
611-
// this should only be true if m_useMyHostname is false and an address without
612-
// an `@` is encountered
613-
614-
os << localPart;
615-
616-
if (newLinePos) {
617-
*newLinePos = curLinePos
618-
+ localPart.length();
619-
}
599+
os << localPart
600+
<< "@"
601+
<< domainPart;
602+
603+
if (newLinePos) {
604+
*newLinePos = curLinePos
605+
+ localPart.length()
606+
+ 1 // @
607+
+ domainPart.length();
620608
}
621609
}
622610

@@ -710,13 +698,8 @@ const text emailAddress::toText() const {
710698

711699
text txt;
712700
txt.appendWord(make_shared <vmime::word>(m_localName));
713-
714-
if (!m_domainName.isEmpty()) {
715-
// this should only be skipped if m_useMyHostname is false and an address without
716-
// an `@` is encountered
717-
txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII));
718-
txt.appendWord(make_shared <vmime::word>(m_domainName));
719-
}
701+
txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII));
702+
txt.appendWord(make_shared <vmime::word>(m_domainName));
720703

721704
return txt;
722705
}

src/vmime/path.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ void path::generateImpl(
192192
*newLinePos = curLinePos + 2;
193193
}
194194

195-
} else if (!m_localPart.empty() && m_domain.empty()) {
196-
// this should only be true if m_useMyHostname is false and an address without
197-
// an `@` is encountered
198-
199-
os << "<" << m_localPart << ">";
200-
201-
if (newLinePos) {
202-
*newLinePos = curLinePos + m_localPart.length() + 2;
203-
}
204-
205195
} else {
206196

207197
os << "<" << m_localPart << "@" << m_domain << ">";

0 commit comments

Comments
 (0)