summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/cjs_runtime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/cjs_runtime.cpp')
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index cb8f69f9da..515bdcb65f 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -218,19 +218,16 @@ CFX_WideString ChangeObjName(const CFX_WideString& str) {
sRet.Replace(L"_", L".");
return sRet;
}
+
bool CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
- const char* name = utf8Name.c_str();
-
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Context> context = NewLocalContext();
v8::Context::Scope context_scope(context);
-
- v8::Local<v8::Value> propvalue =
- context->Global()->Get(v8::String::NewFromUtf8(
- GetIsolate(), name, v8::String::kNormalString, utf8Name.GetLength()));
-
+ v8::Local<v8::Value> propvalue = context->Global()->Get(
+ v8::String::NewFromUtf8(GetIsolate(), utf8Name.unterminated_c_str(),
+ v8::String::kNormalString, utf8Name.GetLength()));
if (propvalue.IsEmpty()) {
pValue->SetUndefined();
return false;
@@ -238,24 +235,22 @@ bool CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
pValue->ForceSetValue(propvalue);
return true;
}
+
bool CJS_Runtime::SetValueByName(const CFX_ByteStringC& utf8Name,
CFXJSE_Value* pValue) {
if (utf8Name.IsEmpty() || !pValue)
return false;
- const char* name = utf8Name.c_str();
+
v8::Isolate* pIsolate = GetIsolate();
v8::Isolate::Scope isolate_scope(pIsolate);
v8::HandleScope handle_scope(pIsolate);
v8::Local<v8::Context> context = NewLocalContext();
v8::Context::Scope context_scope(context);
-
- // v8::Local<v8::Context> tmpCotext =
- // v8::Local<v8::Context>::New(GetIsolate(), m_context);
v8::Local<v8::Value> propvalue =
v8::Local<v8::Value>::New(GetIsolate(), pValue->DirectGetValue());
context->Global()->Set(
- v8::String::NewFromUtf8(pIsolate, name, v8::String::kNormalString,
- utf8Name.GetLength()),
+ v8::String::NewFromUtf8(pIsolate, utf8Name.unterminated_c_str(),
+ v8::String::kNormalString, utf8Name.GetLength()),
propvalue);
return true;
}