mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 22:05:40 +00:00
Bug 153855 Composer does not display a UTF-16 signature in the right way. (with fix UTF-8 BOM problem) r=jshin, sr=mscott
This commit is contained in:
parent
0f94d8ab55
commit
8a7cc628ad
@ -147,7 +147,11 @@ nsresult nsMsgI18NConvertToUnicode(const char* aCharset,
|
||||
}
|
||||
else if (!PL_strcasecmp(aCharset, "UTF-8")) {
|
||||
if (IsUTF8(inString)) {
|
||||
CopyUTF8toUTF16(inString, outString);
|
||||
nsAutoString tmp;
|
||||
CopyUTF8toUTF16(inString, tmp);
|
||||
if (!tmp.IsEmpty() && tmp.get()[0] == PRUnichar(0xFEFF))
|
||||
tmp.Cut(0, 1);
|
||||
outString.Assign(tmp);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_WARNING("Invalid UTF-8 string");
|
||||
|
@ -3504,7 +3504,7 @@ nsMsgCompose::ConvertTextToHTML(nsFileSpec& aSigFile, nsString &aSigData)
|
||||
|
||||
nsresult
|
||||
nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData,
|
||||
PRBool aAllowUTF8)
|
||||
PRBool aAllowUTF8, PRBool aAllowUTF16)
|
||||
{
|
||||
PRInt32 readSize;
|
||||
PRInt32 nGot;
|
||||
@ -3544,6 +3544,12 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData,
|
||||
if (aAllowUTF8 && IsUTF8(nsDependentCString(readBuf))) {
|
||||
sigEncoding.Assign("UTF-8");
|
||||
}
|
||||
else if (sigEncoding.IsEmpty() && aAllowUTF16 &&
|
||||
fSpec.GetFileSize() % 2 == 0 && fSpec.GetFileSize() >= 2 &&
|
||||
((readBuf[0] == char(0xFE) && readBuf[1] == char(0xFF)) ||
|
||||
(readBuf[0] == char(0xFF) && readBuf[1] == char(0xFE)))) {
|
||||
sigEncoding.Assign("UTF-16");
|
||||
}
|
||||
else {
|
||||
//default to platform encoding for plain text files w/o meta charset
|
||||
nsCAutoString textFileCharset;
|
||||
@ -3552,8 +3558,11 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData,
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(ConvertToUnicode(sigEncoding.get(), readBuf, sigData)))
|
||||
CopyASCIItoUTF16(readBuf, sigData);
|
||||
nsCAutoString readStr(readBuf, fSpec.GetFileSize());
|
||||
PR_FREEIF(readBuf);
|
||||
|
||||
if (NS_FAILED(ConvertToUnicode(sigEncoding.get(), readStr, sigData)))
|
||||
CopyASCIItoUTF16(readStr, sigData);
|
||||
|
||||
//remove sig meta charset to allow user charset override during composition
|
||||
if (removeSigCharset)
|
||||
@ -3569,7 +3578,6 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData,
|
||||
sigData.Cut(Distance(realstart, start), Distance(start, end));
|
||||
}
|
||||
|
||||
PR_FREEIF(readBuf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,8 @@ private:
|
||||
|
||||
nsresult LoadDataFromFile(nsFileSpec& fSpec,
|
||||
nsString &sigData,
|
||||
PRBool aAllowUTF8 = PR_TRUE);
|
||||
PRBool aAllowUTF8 = PR_TRUE,
|
||||
PRBool aAllowUTF16 = PR_TRUE);
|
||||
|
||||
/*
|
||||
nsresult GetCompFields(nsMsgCompFields **aCompFields)
|
||||
|
Loading…
x
Reference in New Issue
Block a user