зеркало из https://github.com/mozilla/gecko-dev.git
fix for 237118, patch by Franke@computer.org, r/sr=bienvenu, make sure text like attachments with mixed line endings are binary encoded; otherwise we get corrupted attachments
This commit is contained in:
Родитель
4e52e04582
Коммит
295969203b
|
@ -115,6 +115,7 @@ nsMsgAttachmentHandler::nsMsgAttachmentHandler()
|
|||
m_file_analyzed = PR_FALSE;
|
||||
m_ctl_count = 0;
|
||||
m_null_count = 0;
|
||||
m_have_cr = m_have_lf = m_have_crlf = 0;
|
||||
m_current_column = 0;
|
||||
m_max_column = 0;
|
||||
m_lines = 0;
|
||||
|
@ -198,8 +199,18 @@ nsMsgAttachmentHandler::AnalyzeDataChunk(const char *chunk, PRInt32 length)
|
|||
|
||||
if (*s == nsCRT::CR || *s == nsCRT::LF)
|
||||
{
|
||||
if (s+1 < end && s[0] == nsCRT::CR && s[1] == nsCRT::LF)
|
||||
s++;
|
||||
if (*s == nsCRT::CR)
|
||||
{
|
||||
if (s+1 < end && s[1] == nsCRT::LF)
|
||||
{
|
||||
s++;
|
||||
m_have_crlf = 1;
|
||||
}
|
||||
else
|
||||
m_have_cr = 1;
|
||||
}
|
||||
else
|
||||
m_have_lf = 1;
|
||||
if (m_max_column < m_current_column)
|
||||
m_max_column = m_current_column;
|
||||
m_current_column = 0;
|
||||
|
@ -264,9 +275,11 @@ nsMsgAttachmentHandler::PickEncoding(const char *charset, nsIMsgSend *mime_deliv
|
|||
if (pPrefBranch)
|
||||
pPrefBranch->GetBoolPref ("mail.file_attach_binary", &forceB64);
|
||||
|
||||
if (!mMainBody && (forceB64 || mime_type_requires_b64_p (m_type)))
|
||||
if (!mMainBody && (forceB64 || mime_type_requires_b64_p (m_type) ||
|
||||
m_have_cr+m_have_lf+m_have_crlf != 1 || m_current_column != 0))
|
||||
{
|
||||
/* If the content-type is "image/" or something else known to be binary,
|
||||
/* If the content-type is "image/" or something else known to be binary
|
||||
or several flavors of newlines are present or last line is incomplete,
|
||||
always use base64 (so that we don't get confused by newline
|
||||
conversions.)
|
||||
*/
|
||||
|
|
|
@ -156,6 +156,7 @@ public:
|
|||
PRUint32 m_highbit_count;
|
||||
PRUint32 m_ctl_count;
|
||||
PRUint32 m_null_count;
|
||||
PRUint8 m_have_cr, m_have_lf, m_have_crlf;
|
||||
PRUint32 m_current_column;
|
||||
PRUint32 m_max_column;
|
||||
PRUint32 m_lines;
|
||||
|
|
Загрузка…
Ссылка в новой задаче