Bug 1787121: write runtime shortcuts log in UTF-16LE encoding r=bytesized
It turns out that the INI parser used by NSIS only supports UTF-16LE encoding. Our INI parser doesn't support UTF-16 at all, so we need to a bit of work ourselves to write this file correctly. Differential Revision: https://phabricator.services.mozilla.com/D157378
This commit is contained in:
@@ -767,8 +767,21 @@ static nsresult WriteShortcutToLog(nsIFile* aShortcutsLogDir,
|
|||||||
|
|
||||||
if (!shortcutsLogEntryExists) {
|
if (!shortcutsLogEntryExists) {
|
||||||
parser.SetString(section.get(), keyName.get(), shortcutName.get());
|
parser.SetString(section.get(), keyName.get(), shortcutName.get());
|
||||||
rv = parser.WriteToFile(shortcutsLog);
|
// We write this ourselves instead of using parser->WriteToFile because
|
||||||
|
// the INI parser in our uninstaller needs to read this, and only supports
|
||||||
|
// UTF-16LE encoding. nsINIParser does not support UTF-16.
|
||||||
|
nsAutoCString formatted;
|
||||||
|
parser.WriteToString(formatted);
|
||||||
|
FILE* writeFile;
|
||||||
|
rv = shortcutsLog->OpenANSIFileDesc("w,ccs=UTF-16LE", &writeFile);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
NS_ConvertUTF8toUTF16 formattedUTF16(formatted);
|
||||||
|
if (fwrite(formattedUTF16.get(), sizeof(wchar_t), formattedUTF16.Length(),
|
||||||
|
writeFile) != formattedUTF16.Length()) {
|
||||||
|
fclose(writeFile);
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
fclose(writeFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user