Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a test failure in pathTest::testGenerate #312

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion tests/parser/textTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("2.1", 3, t2.getWordCount());
VASSERT_EQ("2.2", "some ASCII characters and special chars:", t2.getWordAt(0)->getBuffer());
VASSERT_EQ("2.3", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(0)->getCharset());
VASSERT_EQ("2.4", "\xc3\xa4\xd0\xb0", t2.getWordAt(1)->getBuffer());
VASSERT_EQ("2.4", " \xc3\xa4\xd0\xb0", t2.getWordAt(1)->getBuffer());
VASSERT_EQ("2.5", c2, t2.getWordAt(1)->getCharset());
VASSERT_EQ("2.6", " and then more ASCII chars.", t2.getWordAt(2)->getBuffer());
VASSERT_EQ("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset());
Expand Down