summaryrefslogtreecommitdiffstats
path: root/mailnews/local/src/nsParseMailbox.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-10 18:43:43 -0500
committerMatt A. Tobin <email@mattatobin.com>2019-11-10 18:43:43 -0500
commite60090bc9c7e14bb8253eeb64658aedaa0f863c7 (patch)
tree0d8b21f3ff848346d601c34c88bd35c76fb06d0a /mailnews/local/src/nsParseMailbox.cpp
parent1ec388b2383aa1540961843847d3af32174a248d (diff)
downloadUXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.gz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.lz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.tar.xz
UXP-e60090bc9c7e14bb8253eeb64658aedaa0f863c7.zip
Bug 1427732 - fix newline handling when copying messages and compacting folders.
Tag #1273
Diffstat (limited to 'mailnews/local/src/nsParseMailbox.cpp')
-rw-r--r--mailnews/local/src/nsParseMailbox.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp
index 9d68e5cd1..da51c0322 100644
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -598,6 +598,7 @@ NS_IMETHODIMP nsParseMailMessageState::Clear()
m_mdn_original_recipient.length = 0;
m_bccList.length = 0;
m_body_lines = 0;
+ m_lastLineBlank = 0;
m_newMsgHdr = nullptr;
m_envelope_pos = 0;
m_new_key = nsMsgKey_None;
@@ -694,6 +695,9 @@ nsresult nsParseMailMessageState::ParseFolderLine(const char *line, uint32_t lin
else if ( m_state == nsIMsgParseMailMsgState::ParseBodyState)
{
m_body_lines++;
+ // See comment in msgCore.h for why we use `IS_MSG_LINEBREAK` rather than
+ // just comparing `line` to `MSG_LINEBREAK`.
+ m_lastLineBlank = IS_MSG_LINEBREAK(line);
}
m_position += lineLength;
@@ -824,7 +828,9 @@ NS_IMETHODIMP nsParseMailMessageState::FinishHeader()
if (m_newMsgHdr)
{
m_newMsgHdr->SetMessageOffset(m_envelope_pos);
- m_newMsgHdr->SetMessageSize(m_position - m_envelope_pos);
+ if (m_lastLineBlank)
+ m_body_lines--;
+ m_newMsgHdr->SetMessageSize(m_position - m_envelope_pos - m_lastLineBlank);
m_newMsgHdr->SetLineCount(m_body_lines);
}
return NS_OK;
@@ -1888,7 +1894,9 @@ NS_IMETHODIMP nsParseNewMailState::FinishHeader()
{
if (m_newMsgHdr)
{
- m_newMsgHdr->SetMessageSize(m_position - m_envelope_pos);
+ if (m_lastLineBlank)
+ m_body_lines--;
+ m_newMsgHdr->SetMessageSize(m_position - m_envelope_pos - m_lastLineBlank);
m_newMsgHdr->SetLineCount(m_body_lines);
}
return NS_OK;