From 949bfbc7df699670aebe0f18a14428b752ade578 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Wed, 16 Aug 2006 19:54:26 +0000 Subject: [PATCH] fix 348762, uploading message with mixed line endings can produce corrupted messages, sr=mscott git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@207627 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/imap/src/nsImapMailFolder.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index 11c78733251..3c603ea248a 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -3169,10 +3169,8 @@ NS_IMETHODIMP nsImapMailFolder::CopyDataToOutputStreamForAppend(nsIInputStream * start++; m_copyState->m_eatLF = PR_FALSE; } - end = PL_strchr(start, '\r'); - if (!end) - end = PL_strchr(start, '\n'); - else if (*(end+1) == nsCRT::LF) + end = PL_strpbrk(start, "\r\n"); + if (end && *end == '\r' && *(end+1) == '\n') linebreak_len = 2; while (start && end) @@ -3195,13 +3193,14 @@ NS_IMETHODIMP nsImapMailFolder::CopyDataToOutputStreamForAppend(nsIInputStream * } linebreak_len = 1; - end = PL_strchr(start, '\r'); - if (!end) - end = PL_strchr(start, '\n'); - else if (*(end+1) == nsCRT::LF) - linebreak_len = 2; - else if (! *(end+1)) // block might have split CRLF so remember if - m_copyState->m_eatLF = PR_TRUE; // we should eat LF + end = PL_strpbrk(start, "\r\n"); + if (end && *end == '\r') + { + if (*(end+1) == '\n') + linebreak_len = 2; + else if (! *(end+1)) // block might have split CRLF so remember if + m_copyState->m_eatLF = PR_TRUE; // we should eat LF + } if (start && !end) {