Changed to support charset override for message headers, ignore the header specified charset and use the folder charset for the charset conversion,

bug 65277, r=mscott, sr=bienvenu.
This commit is contained in:
nhotta%netscape.com 2001-01-25 23:39:22 +00:00
parent 9250f428f3
commit b29a156ff1
2 changed files with 38 additions and 2 deletions

View File

@ -2649,8 +2649,33 @@ nsresult nsMsgDatabase::RowCellColumnToMime2DecodedString(nsIMdbRow *row, mdb_to
nsAutoString charset;
nsAutoString decodedStr;
PRBool usedDefault;
PRBool characterSetOverride;
m_dbFolderInfo->GetCharacterSet(&charset, &usedDefault);
err = m_mimeConverter->DecodeMimePartIIStr(nakedString, charset, resultStr);
m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
if (!characterSetOverride)
{
err = m_mimeConverter->DecodeMimePartIIStr(nakedString, charset, resultStr);
}
else
{
// if folder charset override is 'ON' then ignore the MIME header and
// always use the folder charset
char *encodedString, *decodedString;
encodedString = nakedString.ToNewCString();
if (encodedString)
{
// do MIME decoding only, ignore charset, no charset conversion
err = m_mimeConverter->DecodeMimePartIIStr(encodedString, nsnull, &decodedString);
if (NS_SUCCEEDED(err))
{
nakedString.AssignWithConversion(decodedString);
// call again only for charset conversion with the folder charset
err = m_mimeConverter->DecodeMimePartIIStr(nakedString, charset, resultStr);
}
PR_FREEIF(decodedString);
PR_FREEIF(encodedString);
}
}
}
}
return err;

View File

@ -127,7 +127,18 @@ nsMimeConverter::DecodeMimePartIIStr(const char *header,
char **decodedString,
PRBool eatContinuations)
{
char *retString = MIME_DecodeMimePartIIStr(header, charset, eatContinuations);
char *retString;
if (charset)
{
retString = MIME_DecodeMimePartIIStr(header, charset, eatContinuations);
}
else
{
// the callder does not care about the charset, pass the local buffer
char charsetCstr[kMAX_CSNAME+1];
*charsetCstr = '\0';
retString = MIME_DecodeMimePartIIStr(header, charsetCstr, eatContinuations);
}
if (retString == NULL)
return NS_ERROR_FAILURE;
else