[gjs: 1/5] Fix UTF8 encoding for some GJS string arrays. - The function that constructs string arrays for impor



commit 89f1ab0f606fb05364fd2f97a0a1e1678134e464
Author: rockon999 <rockon999 users noreply github com>
Date:   Mon Mar 26 19:59:18 2018 -0400

    Fix UTF8 encoding for some GJS string arrays.
    - The function that constructs string arrays for imports and argv utilized a JS_NewStringCopyZ call 
instead of the proper JS_NewStringCopyUTF8Z (the input is UTF8).

 gjs/jsapi-util.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gjs/jsapi-util.cpp b/gjs/jsapi-util.cpp
index 322a41b2..5c91dd2a 100644
--- a/gjs/jsapi-util.cpp
+++ b/gjs/jsapi-util.cpp
@@ -313,8 +313,9 @@ gjs_build_string_array(JSContext   *context,
         g_error("Unable to reserve memory for vector");
 
     for (i = 0; i < array_length; ++i) {
+        JS::ConstUTF8CharsZ chars(array_values[i], strlen(array_values[i]));
         JS::RootedValue element(context,
-            JS::StringValue(JS_NewStringCopyZ(context, array_values[i])));
+            JS::StringValue(JS_NewStringCopyUTF8Z(context, chars)));
         if (!elems.append(element))
             g_error("Unable to append to vector");
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]