Use UTF-8 instead of ASCII for setting object properties from folly::dynamic

Summary:
Based on Hermes Issue: https://github.com/facebook/hermes/issues/47
It was not actually a bug in Hermes, but a bug in JSI, assuming that all string property names from
`folly::dynamic` are ASCII.

Now we'll be more intentional and directly state `forUtf8` rather than the implicit ASCII encoding.

Reviewed By: mhorowitz

Differential Revision: D16347857

fbshipit-source-id: 6bcfbf9f918dc0a7a485b88a1b537d6c2dd322cc
This commit is contained in:
Riley Dulin
2019-07-17 17:05:47 -07:00
committed by Facebook Github Bot
parent 96be82e3f9
commit c24387e45c
+4 -1
View File
@@ -41,7 +41,10 @@ Value valueFromDynamic(Runtime& runtime, const folly::dynamic& dyn) {
for (const auto& element : dyn.items()) {
Value value = valueFromDynamic(runtime, element.second);
if (element.first.isNumber() || element.first.isString()) {
ret.setProperty(runtime, element.first.asString().c_str(), value);
ret.setProperty(
runtime,
PropNameID::forUtf8(runtime, element.first.asString()),
value);
}
}
return std::move(ret);