Fix for 209699 (bug convert some consumers over to CopyUTF8toUTF16 / CopyUTF16toUTF8). r=jshin, sr=jst.

git-svn-id: svn://10.0.0.236/trunk@162452 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
peterv%propagandism.org 2004-09-16 13:16:28 +00:00
parent 49a0c9fc4b
commit 0ad8754061
27 changed files with 60 additions and 64 deletions

View File

@ -222,8 +222,7 @@ nsresult nsAbAddressCollecter::AutoCollectScreenName(nsIAbCard *aCard, const cha
strcmp(domain,"netscape.net"))
return NS_OK;
nsAutoString userName(NS_ConvertASCIItoUCS2(aEmail).get());
userName.SetLength(atPos - aEmail);
NS_ConvertASCIItoUTF16 userName(Substring(aEmail, atPos));
rv = aCard->SetAimScreenName(userName.get());
NS_ENSURE_SUCCESS(rv,rv);

View File

@ -572,7 +572,7 @@ nsAbLDAPAutoCompFormatter::ProcessFormat(const nsAString & aFormat,
// this character gets treated as a literal
//
(*aValue).Append(NS_ConvertUCS2toUTF8(nsDependentString(iter.get(), 1))); //XXXjag poke me about string generators
AppendUTF16toUTF8(nsDependentString(iter.get(), 1), *aValue); //XXXjag poke me about string generators
}
}
@ -690,7 +690,7 @@ nsAbLDAPAutoCompFormatter::AppendFirstAttrValue(
// append the value to our string; then free the array of results
//
aValue.Append(NS_ConvertUCS2toUTF8(values[0]));
AppendUTF16toUTF8(values[0], aValue);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numVals, values);
// if this attribute wasn't required, we fall through to here, and return

View File

@ -292,9 +292,8 @@ nsresult nsAbLDAPProcessChangeLogData::GetAuthData()
getter_Copies(username), getter_Copies(password),
&btnResult);
if(NS_SUCCEEDED(rv) && btnResult) {
// XXX This needs CopyUCS2toUTF8
mAuthUserID.Assign(NS_ConvertUCS2toUTF8(username));
mAuthPswd.Assign(NS_ConvertUCS2toUTF8(password));
CopyUTF16toUTF8(username, mAuthUserID);
CopyUTF16toUTF8(password, mAuthPswd);
mDirServerInfo->enableAuth=PR_TRUE;
mDirServerInfo->savePassword=PR_TRUE;
}
@ -342,8 +341,7 @@ nsresult nsAbLDAPProcessChangeLogData::ParseRootDSEEntry(nsILDAPMessage *aMessag
continue;
if(vals.GetSize()) {
if (!PL_strcasecmp(attrs[i], "changelog"))
// XXX This needs CopyUCS2toUTF8
mRootDSEEntry.changeLogDN.Assign(NS_ConvertUCS2toUTF8(vals[0]));
CopyUTF16toUTF8(vals[0], mRootDSEEntry.changeLogDN);
if (!PL_strcasecmp(attrs[i], "firstChangeNumber"))
mRootDSEEntry.firstChangeNumber = atol(NS_LossyConvertUCS2toASCII(vals[0]).get());
if (!PL_strcasecmp(attrs[i], "lastChangeNumber"))

View File

@ -271,7 +271,6 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::PopulateAuthData()
return rv;
if (!passwordFound.IsEmpty())
// XXX This needs CopyUCS2toUTF8
CopyUTF16toUTF8(passwordFound, mAuthPswd);
}

View File

@ -155,7 +155,7 @@ nsAddbookProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
rv = aURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv,rv);
errorString.Append(NS_ConvertUTF8toUCS2(spec));
AppendUTF8toUTF16(spec, errorString);
rv = GenerateXMLOutputChannel(errorString, addbookUrl, aURI, _retval);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
@ -183,7 +183,7 @@ nsAddbookProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
nsCAutoString spec;
rv = aURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv,rv);
output.Append(NS_ConvertUTF8toUCS2(spec));
AppendUTF8toUTF16(spec, output);
}
rv = GenerateXMLOutputChannel(output, addbookUrl, aURI, _retval);

View File

@ -518,7 +518,7 @@ nsresult AddressBookParser::ParseFile()
// If a name is found then use it, otherwise use the filename as last resort.
if (NS_FAILED(rv) || dirName.IsEmpty())
dirName = NS_ConvertASCIItoUCS2(leafName);
CopyASCIItoUTF16(leafName, dirName);
parentDir->CreateDirectoryByURI(dirName, mDbUri, mMigrating);
rv = ParseLDIFFile();
@ -1897,7 +1897,8 @@ nsresult nsAddressBook::AppendProperty(const char *aProperty, const PRUnichar *a
// if the string is not safe "as is", base64 encode it
if (IsSafeLDIFString(aValue)) {
aResult += NS_LITERAL_CSTRING(": ") + NS_LossyConvertUCS2toASCII(aValue);
aResult.AppendLiteral(": ");
LossyAppendUTF16toASCII(aValue, aResult);
}
else {
char *base64Str = PL_Base64Encode(NS_ConvertUCS2toUTF8(aValue).get(), 0, nsnull);

View File

@ -402,7 +402,7 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsIMsgRuleAction *aFilterAction, nsIMsgDBH
buffer.SetCapacity(512);
buffer = "Applied filter \"";
buffer += NS_ConvertUCS2toUTF8(filterName).get();
AppendUTF16toUTF8(filterName, buffer);
buffer += "\" to message from ";
buffer += (const char*)author;
buffer += " - ";

View File

@ -229,10 +229,10 @@ char *nsMsgSearchNews::EncodeTerm (nsIMsgSearchTerm *term)
if (leadingStar)
pattern.Append("*");
pattern.Append(NS_ConvertUCS2toUTF8(escapedValue));
pattern.Append('*');
AppendUTF16toUTF8(escapedValue, pattern);
if (trailingStar)
pattern.Append("*");
pattern.Append('*');
// Combine the XPAT command syntax with the attribute and the pattern to
// form the term encoding

View File

@ -114,7 +114,7 @@ nsMsgSearchValueImpl::ToString(PRUnichar **aResult)
nsAutoString resultStr;
resultStr.AssignLiteral("[nsIMsgSearchValue: ");
if (IS_STRING_ATTRIBUTE(mValue.attribute)) {
resultStr.Append(NS_ConvertUTF8toUCS2(mValue.string));
AppendUTF8toUTF16(mValue.string, resultStr);
return NS_OK;
}

View File

@ -611,7 +611,7 @@ nsMessenger::LoadURL(nsIDOMWindowInternal *aWin, const char *aURL)
SetDisplayCharset("UTF-8");
nsAutoString uriString(NS_ConvertASCIItoUCS2(aURL).get());
NS_ConvertASCIItoUTF16 uriString(aURL);
// Cleanup the empty spaces that might be on each end.
uriString.Trim(" ");
// Eliminate embedded newlines, which single-line text fields now allow:
@ -2031,7 +2031,8 @@ nsSaveMsgListener::OnDataAvailable(nsIRequest* request,
if (NS_SUCCEEDED(rv))
{
if ( (m_doCharsetConversion) && (m_outputFormat == ePlainText) )
m_msgBuffer.Append(NS_ConvertUTF8toUCS2(m_dataBuffer, readCount));
AppendUTF8toUTF16(Substring(m_dataBuffer, m_dataBuffer + readCount),
m_msgBuffer);
else
rv = m_outputStream->Write(m_dataBuffer, readCount, &writeCount);

View File

@ -1796,8 +1796,9 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs
if (!myGetter.IsEmpty())
{
nsCAutoString buf;
mCiteReference = NS_LITERAL_STRING("mid")
+ NS_ConvertASCIItoUCS2(NS_EscapeURL(myGetter, esc_FileBaseName | esc_Forced, buf));
mCiteReference.AssignLiteral("mid");
AppendASCIItoUTF16(NS_EscapeURL(myGetter, esc_FileBaseName | esc_Forced, buf),
mCiteReference);
}
}

View File

@ -47,8 +47,8 @@
extern PRLogModuleInfo *PALMSYNC;
#define CONVERT_ASSIGNTO_UNICODE(d, s, convertCRLF) d.SetLength(0);\
if((char*) s) d=NS_ConvertASCIItoUCS2((const char*)s);\
#define CONVERT_ASSIGNTO_UNICODE(d, s, convertCRLF) d.Truncate();\
if((char*) s) AppendASCIItoUTF16((char*)s, d);\
if (convertCRLF) \
d.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),NS_LITERAL_STRING(" ").get());
@ -819,8 +819,7 @@ void nsAbIPCCard::CopyValue(PRBool isUnicode, nsString & attribValue, LPTSTR * r
*result = Str;
}
else {
nsCAutoString cStr;
cStr = NS_LossyConvertUCS2toASCII(attribValue);
NS_LossyConvertUTF16toASCII cStr(attribValue);
// These strings are defined as wide in the idl, so we need to add up to 3
// bytes of 0 byte padding at the end (if the string is an odd number of
// bytes long, we need one null byte to pad out the last char to a wide char
@ -947,15 +946,14 @@ void nsAbIPCCard::JoinAddress(PRBool isUnicode, LPTSTR *ptrAddress, nsString &ad
else
{
char * str = (char *) CoTaskMemAlloc(strLength);
nsCAutoString cStr;
if(address1.Length())
{
cStr = NS_LossyConvertUCS2toASCII(address1);
NS_LossyConvertUTF16toASCII cStr(address1);
strncpy(str, cStr.get(), strLength-1);
str[strLength-1] = '\0';
if(address2.Length())
{
cStr = NS_LossyConvertUCS2toASCII(address2);
LossyCopyUTF16toASCII(address2, cStr);
strncat(str, "\x0A", strLength-1);
strncat(str, cStr.get(), strLength-1);
str[strLength-1] = '\0';
@ -963,7 +961,7 @@ void nsAbIPCCard::JoinAddress(PRBool isUnicode, LPTSTR *ptrAddress, nsString &ad
}
else
{
cStr = NS_LossyConvertUCS2toASCII(address2);
NS_LossyConvertUTF16toASCII cStr(address2);
strncpy(str, cStr.get(), strLength-1);
str[strLength-1] = '\0';
}

View File

@ -128,7 +128,7 @@ nsAbPalmHotSync::nsAbPalmHotSync(PRBool aIsUnicode, PRUnichar * aAbDescUnicode,
if(aIsUnicode)
mAbName.Assign(aAbDescUnicode);
else
mAbName = NS_ConvertASCIItoUCS2(aAbDesc);
CopyASCIItoUTF16(aAbDesc, mAbName);
mAbName.Trim(" ");
mPalmCategoryIndex = aPalmCatIndex;

View File

@ -414,21 +414,20 @@ nsresult nsSMimeJSHelper::getMailboxList(nsIMsgCompFields *compFields, PRUint32
{
nsCString all_recipients;
nsDependentCString comma(",");
NS_ConvertUCS2toUTF8 utf8_to(to);
if (!utf8_to.IsEmpty()) {
all_recipients += utf8_to + comma;
if (!to.IsEmpty()) {
AppendUTF16toUTF8(to, all_recipients);
all_recipients.Append(',');
}
NS_ConvertUCS2toUTF8 utf8_cc(cc);
if (!utf8_cc.IsEmpty()) {
all_recipients += utf8_cc + comma;
if (!cc.IsEmpty()) {
AppendUTF16toUTF8(cc, all_recipients);
all_recipients.Append(',');
}
NS_ConvertUCS2toUTF8 utf8_bcc(bcc);
if (!utf8_bcc.IsEmpty()) {
all_recipients += utf8_bcc + comma;
if (!bcc.IsEmpty()) {
AppendUTF16toUTF8(bcc, all_recipients);
all_recipients.Append(',');
}
all_recipients += ng;

View File

@ -1105,8 +1105,8 @@ nsresult nsImapIncomingServer::GetPFCForStringId(PRBool createIfMissing, PRInt32
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString pfcMailUri(pfcURI);
// pfcMailUri.Append(".sbd");
pfcMailUri.Append("/");
pfcMailUri.Append(NS_ConvertUCS2toUTF8(pfcName).get());
pfcMailUri.Append('/');
AppendUTF16toUTF8(pfcName, pfcMailUri);
pfcParent->GetChildWithURI(pfcMailUri.get(), PR_FALSE, PR_FALSE /* caseInsensitive*/, aFolder);
if (!*aFolder && createIfMissing)
{
@ -2087,7 +2087,7 @@ NS_IMETHODIMP nsImapIncomingServer::FEAlertFromServer(const char *aString, nsIM
nsAutoString message(serverSaidPrefix);
// the alert string from the server IS UTF-8!!! We must convert it to unicode
// correctly before appending it to our error message string...
message.Append(NS_ConvertUTF8toUCS2(whereRealMessage ? whereRealMessage : aString));
AppendUTF8toUTF16(whereRealMessage ? whereRealMessage : aString, message);
rv = dialog->Alert(nsnull, message.get());
PR_Free(serverSaidPrefix);

View File

@ -5266,7 +5266,7 @@ nsImapMailFolder::FillInFolderProps(nsIMsgImapFolderProps *aFolderProps)
else
{
// is this right? It doesn't leak, does it?
uniOwner.Assign(NS_ConvertASCIItoUCS2(owner.get()));
CopyASCIItoUTF16(owner, uniOwner);
}
const PRUnichar *params[] = { uniOwner.get() };
rv = bundle->FormatStringFromID(IMAP_OTHER_USERS_FOLDER_TYPE_DESCRIPTION, params, 1, getter_Copies(folderTypeDesc));

View File

@ -328,7 +328,7 @@ nsresult OESettings::GetAccountName(HKEY hKey, char *defaultName, nsString &acct
nsOERegUtil::FreeValueBytes( pAccName);
}
else
acctName.Assign(NS_ConvertASCIItoUCS2(defaultName));
CopyASCIItoUTF16(defaultName, acctName);
return rv;
}

View File

@ -614,7 +614,7 @@ nsresult nsOutlookCompose::SendTheMessage( nsIFileSpec *pMsg, nsMsgDeliverMode m
// If callers pass in a content type then use it, else get it from the header.
if (!useThisCType.IsEmpty())
bodyType.Assign(NS_ConvertASCIItoUCS2(useThisCType.get()));
CopyASCIItoUTF16(useThisCType, bodyType);
else
{
bodyType = headerVal;

View File

@ -147,7 +147,7 @@ private:
val.Truncate();
nsCString hVal;
GetHeaderValue( pData, dataLen, pHeader, hVal, PR_TRUE);
val.Assign(NS_ConvertUTF8toUCS2(hVal));
CopyUTF8toUTF16(hVal, val);
}
void ExtractCharset( nsString& str);
void ExtractType( nsString& str);

View File

@ -285,7 +285,7 @@ nsresult OutlookSettings::GetAccountName(HKEY hKey, char *defaultName, nsString
nsOutlookRegUtil::FreeValueBytes( pAccName);
}
else
acctName.Assign(NS_ConvertASCIItoUCS2(defaultName));
CopyASCIItoUTF16(defaultName, acctName);
return rv;
}

View File

@ -1077,8 +1077,8 @@ nsPop3Protocol::Error(PRInt32 err_code)
}
nsAutoString message(alertString + NS_LITERAL_STRING(" ") +
serverSaidPrefix + NS_LITERAL_STRING(" ") +
NS_ConvertASCIItoUCS2(m_commandResponse));
serverSaidPrefix + NS_LITERAL_STRING(" "));
AppendASCIItoUTF16(m_commandResponse, message);
dialog->Alert(nsnull,message.get());
}
}

View File

@ -398,7 +398,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name,
if (NS_FAILED(rv))
{
unicodeHeaderValue.Assign(NS_ConvertUTF8toUCS2(name));
CopyUTF8toUTF16(name, unicodeHeaderValue);
// but it's not really a failure if we didn't have a converter
// in the first place

View File

@ -120,7 +120,7 @@ MimeInlineTextHTMLAsPlaintext_parse_eof (MimeObject *obj, PRBool abort_p)
| nsIDocumentEncoder::OutputBodyOnly;
HTML2Plaintext(cb, asPlaintext, flags, 80);
nsCAutoString resultCStr = NS_ConvertUCS2toUTF8(asPlaintext);
NS_ConvertUTF16toUTF8 resultCStr(asPlaintext);
// TODO parse each line independently
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_line(
resultCStr.BeginWriting(),

View File

@ -182,7 +182,7 @@ printf(" E4\n");
printf(" E5\n");
#endif
nsCAutoString resultCStr = NS_ConvertUCS2toUTF8(sanitized);
NS_ConvertUTF16toUTF8 resultCStr(sanitized);
#ifdef DEBUG_BenB
printf(" E6\n");
#endif

View File

@ -120,9 +120,9 @@ nsMimeConverter::DecodeMimeHeader(const char *header,
decodedCstr = MIME_DecodeMimeHeader(header, default_charset,
override_charset, eatContinuations);
if (nsnull == decodedCstr) {
decodedString = NS_ConvertUTF8toUCS2(header);
CopyUTF8toUTF16(header, decodedString);
} else {
decodedString = NS_ConvertUTF8toUCS2(decodedCstr);
CopyUTF8toUTF16(decodedCstr, decodedString);
PR_FREEIF(decodedCstr);
}

View File

@ -1719,7 +1719,7 @@ nsPrefMigration::DoTheCopyAndRename(nsIFileSpec * aPathSpec, PRBool aReadSubdirs
rv = NS_FileSpecToIFile(&path, getter_AddRefs(localFileDirectory));
if (NS_FAILED(rv))
return rv;
nsAutoString newName = NS_ConvertUTF8toUCS2(aNewName);
NS_ConvertUTF8toUTF16 newName(aNewName);
localFileOld->CopyTo(localFileDirectory, newName);
return NS_OK;

View File

@ -1124,9 +1124,9 @@ nsProfileAccess::Get4xProfileInfo(nsIFile *registryFile, PRBool fromImport)
#if defined(XP_MAC) || defined(XP_MACOSX)
// 4.x profiles coming from japanese machine are already in unicode.
// So, there is no need to decode into unicode further.
NS_ConvertUCS2toUTF8 temp(profile);
NS_ConvertUTF16toUTF8 temp(profile);
nsCAutoString profileName(nsUnescape(temp.BeginWriting()));
nsAutoString convertedProfName(NS_ConvertUTF8toUCS2(profileName).get());
NS_ConvertUTF8toUTF16 convertedProfName(profileName);
#else
nsCAutoString temp; temp.AssignWithConversion(profile);
@ -1415,9 +1415,9 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe
// So, there is no need to decode into unicode further.
// Unescape profile location
NS_ConvertUCS2toUTF8 tempLoc(profLoc);
NS_ConvertUTF16toUTF8 tempLoc(profLoc);
nsCAutoString profileLocation(nsUnescape(tempLoc.BeginWriting()));
nsAutoString convertedProfLoc(NS_ConvertUTF8toUCS2(profileLocation).get());
NS_ConvertUTF8toUTF16 convertedProfLoc(profileLocation);
#else
nsCAutoString charSet;
rv = GetPlatformCharset(charSet);
@ -1504,7 +1504,7 @@ nsresult ProfileStruct::ExternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe
if (NS_FAILED(rv)) return rv;
if (leafCreated)
resolvedLocation->Remove(PR_FALSE);
regData = NS_ConvertUTF8toUCS2(descBuf);
AppendUTF8toUTF16(descBuf, regData);
#else
rv = resolvedLocation->GetPath(regData);
if (NS_FAILED(rv)) return rv;
@ -1572,7 +1572,7 @@ nsresult ProfileStruct::ExternalizeMigratedFromLocation(nsIRegistry *aRegistry,
#else
nsAutoString path;
rv = migratedFrom->GetPath(path);
regData = NS_ConvertUCS2toUTF8(path);
AppendUTF16toUTF8(path, regData);
#endif
if (NS_SUCCEEDED(rv))