summaryrefslogtreecommitdiff
path: root/mailnews
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-10 21:18:30 -0500
committerMatt A. Tobin <email@mattatobin.com>2019-11-10 21:18:30 -0500
commitfdcb16661603d4aff52480ba1d68f37562d1dc4d (patch)
tree377d23a538036bed8a773da5329d979d959a1a68 /mailnews
parente661493bb0440e66b4c8af56a81c88e878dd1365 (diff)
downloaduxp-fdcb16661603d4aff52480ba1d68f37562d1dc4d.tar.gz
Bug 145113 - Make "next chunk starts with newline" flag a member variable to fix MOZ_ASSERT().
Tag #1273
Diffstat (limited to 'mailnews')
-rw-r--r--mailnews/imap/src/nsImapServerResponseParser.cpp18
-rw-r--r--mailnews/imap/src/nsImapServerResponseParser.h3
2 files changed, 12 insertions, 9 deletions
diff --git a/mailnews/imap/src/nsImapServerResponseParser.cpp b/mailnews/imap/src/nsImapServerResponseParser.cpp
index b534c4d5bd..fb51db217d 100644
--- a/mailnews/imap/src/nsImapServerResponseParser.cpp
+++ b/mailnews/imap/src/nsImapServerResponseParser.cpp
@@ -36,6 +36,7 @@ nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProto
fSelectedMailboxName(nullptr),
fIMAPstate(kNonAuthenticated),
fLastChunk(false),
+ fNextChunkStartsWithNewline(false),
fServerConnection(imapProtocolConnection),
fHostSessionList(nullptr)
{
@@ -3110,7 +3111,6 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
#endif
charsReadSoFar = 0;
- static bool nextChunkStartsWithNewline = false;
while (ContinueParse() && !fServerConnection.DeathSignalReceived() && (charsReadSoFar < numberOfCharsInThisChunk))
{
@@ -3125,7 +3125,7 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
// '\r' is not inserted so the beginning line of the next chunk remains
// just '\n' and no discard is required.
// In any case, this "orphan" line is ignored and not processed below.
- if (nextChunkStartsWithNewline && (*fCurrentLine == '\r'))
+ if (fNextChunkStartsWithNewline && (*fCurrentLine == '\r'))
{
// Cause fCurrentLine to point to '\n' which discards the '\r'.
char *usableCurrentLine = PL_strdup(fCurrentLine + 1);
@@ -3190,11 +3190,11 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
(fCurrentLine + strlen(fCurrentLine) - (charsReadSoFar - numberOfCharsInThisChunk + 1));
// Save so original unmodified fCurrentLine is restored below.
char saveit1 = displayEndOfLine[1];
- char saveit2;
+ char saveit2 = 0; // Keep compiler happy.
// Determine if EOL is split such that Chunk X has the \r and chunk
// X+1 has the \n.
- nextChunkStartsWithNewline = (displayEndOfLine[0] == '\r');
- if (nextChunkStartsWithNewline)
+ fNextChunkStartsWithNewline = (displayEndOfLine[0] == '\r');
+ if (fNextChunkStartsWithNewline)
{
saveit2 = displayEndOfLine[2];
// Add the missing newline and terminate the string.
@@ -3212,13 +3212,13 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
fServerConnection.HandleMessageDownLoadLine(fCurrentLine, !lastChunk);
// Restore fCurrentLine's original content.
displayEndOfLine[1] = saveit1;
- if (nextChunkStartsWithNewline)
+ if (fNextChunkStartsWithNewline)
displayEndOfLine[2] = saveit2;
}
else
{
// Not the last line of a chunk.
- if (!nextChunkStartsWithNewline)
+ if (!fNextChunkStartsWithNewline)
{
// Process unmodified fCurrentLine string.
fServerConnection.HandleMessageDownLoadLine(fCurrentLine,
@@ -3230,7 +3230,7 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
// Ignore the orphan '\n' on a line by itself.
MOZ_ASSERT(strlen(fCurrentLine) == 1 && fCurrentLine[0] == '\n',
"Expect '\n' as only character in this line");
- nextChunkStartsWithNewline = false;
+ fNextChunkStartsWithNewline = false;
}
}
}
@@ -3253,7 +3253,7 @@ bool nsImapServerResponseParser::msg_fetch_literal(bool chunk, int32_t origin)
}
else
{
- nextChunkStartsWithNewline = false;
+ fNextChunkStartsWithNewline = false;
}
return lastChunk;
}
diff --git a/mailnews/imap/src/nsImapServerResponseParser.h b/mailnews/imap/src/nsImapServerResponseParser.h
index fb5762b6b4..4a21de9059 100644
--- a/mailnews/imap/src/nsImapServerResponseParser.h
+++ b/mailnews/imap/src/nsImapServerResponseParser.h
@@ -256,6 +256,9 @@ private:
int32_t charsReadSoFar;
bool fLastChunk;
+ // Flags split of \r and \n between chunks in msg_fetch_literal().
+ bool fNextChunkStartsWithNewline;
+
// points to the current body shell, if any
RefPtr<nsIMAPBodyShell> m_shell;