Bug 1806169 - Use UTF8 JS parser for nsFrameMessageManager r=hsivonen

Depends on D164931

Differential Revision: https://phabricator.services.mozilla.com/D164932
This commit is contained in:
Ted Campbell 2022-12-23 21:26:25 +00:00
parent 8a0dc3914f
commit ed4d49bc57

View File

@ -1298,7 +1298,7 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
rv = channel->Open(getter_AddRefs(input));
NS_ENSURE_SUCCESS(rv, nullptr);
nsString dataString;
char16_t* dataStringBuf = nullptr;
Utf8Unit* dataStringBuf = nullptr;
size_t dataStringLength = 0;
if (input) {
nsCString buffer;
@ -1308,12 +1308,11 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
}
uint32_t size = (uint32_t)std::min(written, (uint64_t)UINT32_MAX);
ScriptLoader::ConvertToUTF16(channel, (uint8_t*)buffer.get(), size,
u""_ns, nullptr, dataStringBuf,
dataStringLength);
ScriptLoader::ConvertToUTF8(channel, (uint8_t*)buffer.get(), size, u""_ns,
nullptr, dataStringBuf, dataStringLength);
}
if (!dataStringBuf || dataStringLength == 0) {
if (!dataStringBuf) {
return nullptr;
}
@ -1327,10 +1326,9 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
options.setSourceIsLazy(false);
}
JS::UniqueTwoByteChars srcChars(dataStringBuf);
JS::SourceText<char16_t> srcBuf;
if (!srcBuf.init(cx, std::move(srcChars), dataStringLength)) {
JS::SourceText<Utf8Unit> srcBuf;
if (!srcBuf.init(cx, dataStringBuf, dataStringLength,
JS::SourceOwnership::TakeOwnership)) {
return nullptr;
}