ALT Linux Bugzilla
– Attachment 2431 Details for
Bug 14378
Обновить версию
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
патч исправляющий неправильную кодировку темы некоторых писем
thunderbird-charset.patch (text/plain), 7.15 KB, created by
Alexey Sidorov
on 2008-02-10 20:03:03 MSK
(
hide
)
Description:
патч исправляющий неправильную кодировку темы некоторых писем
Filename:
MIME Type:
Creator:
Alexey Sidorov
Created:
2008-02-10 20:03:03 MSK
Size:
7.15 KB
patch
obsolete
>--- mozilla/mailnews/base/util/nsMsgDBFolder.cpp.orig 2007-04-30 21:31:17 +0400 >+++ mozilla/mailnews/base/util/nsMsgDBFolder.cpp 2008-02-10 14:14:56 +0300 >@@ -5232,16 +5232,17 @@ NS_IMETHODIMP nsMsgDBFolder::GetMsgTextF > > nsCString msgText; > nsCAutoString encoding; > nsCAutoString boundary; > nsCAutoString curLine; > > // might want to use a state var instead of bools. > PRBool inMsgBody = PR_FALSE, msgBodyIsHtml = PR_FALSE, lookingForBoundary = PR_FALSE; >+ PRBool lookingForCharset = PR_FALSE; > PRBool haveBoundary = PR_FALSE; > PRBool isBase64 = PR_FALSE; > PRBool reachedEndBody = bytesToRead >= len; > PRBool more = PR_TRUE; > while (len > 0 && more) > { > // might be on same line as content-type, so look before > // we read the next line. >@@ -5296,22 +5297,28 @@ NS_IMETHODIMP nsMsgDBFolder::GetMsgTextF > continue; > } > if (curLine.IsEmpty()) > { > inMsgBody = PR_TRUE; > continue; > } > if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Type:"), >- nsCaseInsensitiveCStringComparator())) >+ nsCaseInsensitiveCStringComparator()) || >+ lookingForCharset) > { > // look for a charset in the Content-Type header line, we'll take the first one we find. > nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); > if (NS_SUCCEEDED(rv) && charset.IsEmpty()) > mimehdrpar->GetParameter(curLine, "charset", EmptyCString(), false, nsnull, charset); >+ // if the Content-Type header is multiline, look for a charset in other lines >+ if (charset.IsEmpty()) >+ lookingForCharset = PR_TRUE; >+ else if (lookingForCharset || (curLine[0] != ' ' && curLine[0] != '\t')) >+ lookingForCharset = PR_FALSE; > if (FindInReadable(NS_LITERAL_CSTRING("text/html"), curLine, > nsCaseInsensitiveCStringComparator())) > msgBodyIsHtml = PR_TRUE; > else if (FindInReadable(NS_LITERAL_CSTRING("multipart/"), curLine, > nsCaseInsensitiveCStringComparator())) > lookingForBoundary = PR_TRUE; > } > else if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Transfer-Encoding:"), >--- mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp.orig 2007-10-03 04:10:16 +0400 >+++ mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp 2008-02-10 14:23:43 +0300 >@@ -3180,22 +3180,29 @@ nsresult nsMsgDatabase::RowCellColumnToM > const char *nakedString = nsnull; > err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString); > if (NS_SUCCEEDED(err) && nakedString && strlen(nakedString)) > { > GetMimeConverter(); > if (m_mimeConverter) > { > nsAutoString decodedStr; >- const char *charSet; >+ char *charSet; > PRBool characterSetOverride; >- m_dbFolderInfo->GetConstCharPtrCharacterSet(&charSet); > m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride); >- >+ err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet); >+ if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") || >+ characterSetOverride) >+ { >+ PR_Free(charSet); >+ m_dbFolderInfo->GetCharPtrCharacterSet(&charSet); >+ } >+ > err = m_mimeConverter->DecodeMimeHeader(nakedString, resultStr, charSet, characterSetOverride); >+ PR_Free(charSet); > } > } > return err; > } > > nsresult nsMsgDatabase::RowCellColumnToAddressCollationKey(nsIMdbRow *row, mdb_token colToken, PRUint8 **result, PRUint32 *len) > { > const char *cSender; >@@ -3210,19 +3217,25 @@ nsresult nsMsgDatabase::RowCellColumnToA > // apply mime decode > nsIMimeConverter *converter = GetMimeConverter(); > > if (NS_SUCCEEDED(ret) && nsnull != converter) > { > char *resultStr = nsnull; > char *charset; > PRBool characterSetOverride; >- m_dbFolderInfo->GetCharPtrCharacterSet(&charset); > m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride); >- >+ ret = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charset); >+ if (NS_FAILED(ret) || !*charset || !PL_strcasecmp(charset, "us-ascii") || >+ characterSetOverride) >+ { >+ PR_Free(charset); >+ m_dbFolderInfo->GetCharPtrCharacterSet(&charset); >+ } >+ > ret = converter->DecodeMimeHeader(cSender, &resultStr, > charset, characterSetOverride); > if (NS_SUCCEEDED(ret) && resultStr) > { > ret = headerParser->ExtractHeaderAddressName ("UTF-8", resultStr, getter_Copies(name)); > } > else { > ret = headerParser->ExtractHeaderAddressName ("UTF-8", cSender, getter_Copies(name)); >@@ -3280,24 +3293,31 @@ nsresult nsMsgDatabase::RowCellColumnToC > > err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString); > if (NS_SUCCEEDED(err)) > { > GetMimeConverter(); > if (m_mimeConverter) > { > nsXPIDLCString decodedStr; >- const char *charSet; >+ char *charSet; > PRBool characterSetOverride; >- m_dbFolderInfo->GetConstCharPtrCharacterSet(&charSet); > m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride); >+ err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet); >+ if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") || >+ characterSetOverride) >+ { >+ PR_Free(charSet); >+ m_dbFolderInfo->GetCharPtrCharacterSet(&charSet); >+ } > > err = m_mimeConverter->DecodeMimeHeader(nakedString, getter_Copies(decodedStr), charSet, characterSetOverride); > if (NS_SUCCEEDED(err)) > err = CreateCollationKey(NS_ConvertUTF8toUCS2(decodedStr), result, len); >+ PR_Free(charSet); > } > } > return err; > } > > NS_IMETHODIMP > nsMsgDatabase::CompareCollationKeys(PRUint8 *key1, PRUint32 len1, PRUint8 *key2, PRUint32 len2, PRInt32 *result) > { >--- mozilla/mailnews/mime/src/mimemsg.cpp.orig 2004-06-10 19:58:10 +0400 >+++ mozilla/mailnews/mime/src/mimemsg.cpp 2008-02-10 14:27:08 +0300 >@@ -744,16 +744,29 @@ MimeMessage_write_headers_html (MimeObje > // reply and forward operations. > // > char *mailCharset = DetermineMailCharset(msg); > mimeEmitterStartHeader(obj->options, > outer_p, > (obj->options->headers == MimeHeadersOnly), > msgID, > mailCharset); >+ >+ // Change the default_charset by the charset of the original message >+ // ONLY WHEN THE CHARSET OF THE ORIGINAL MESSAGE IS NOT US-ASCII >+ // ("ISO-8859-1") and defailt_charset and mailCharset are different. >+ if ( (mailCharset) && (PL_strcasecmp(mailCharset, "US-ASCII")) && >+ (PL_strcasecmp(mailCharset, "ISO-8859-1")) && >+ (PL_strcasecmp(obj->options->default_charset, mailCharset)) && >+ !obj->options->override_charset ) >+ { >+ PR_Free(obj->options->default_charset); >+ obj->options->default_charset = strdup(mailCharset); >+ } >+ > PR_FREEIF(msgID); > PR_FREEIF(mailCharset); > > #ifdef MOZ_SECURITY > HG00919 > #endif /* MOZ_SECURITY */ > > status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, PR_FALSE);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 14378
: 2431