From c24387e45c0d99dc059f2f7bbaa76be47f3f40c2 Mon Sep 17 00:00:00 2001 From: Riley Dulin Date: Wed, 17 Jul 2019 17:00:11 -0700 Subject: [PATCH] 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 --- ReactCommon/jsi/jsi/JSIDynamic.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ReactCommon/jsi/jsi/JSIDynamic.cpp b/ReactCommon/jsi/jsi/JSIDynamic.cpp index fc08ddc35d4..e2dd4f11fb5 100644 --- a/ReactCommon/jsi/jsi/JSIDynamic.cpp +++ b/ReactCommon/jsi/jsi/JSIDynamic.cpp @@ -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);