mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
Fix v8_str internalize bug
This commit is contained in:
parent
1770a77bca
commit
df54db7762
4 changed files with 17 additions and 11 deletions
|
@ -262,8 +262,8 @@ deno_mod DenoIsolate::RegisterModule(const char* name, const char* source) {
|
|||
auto context = context_.Get(isolate_);
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
v8::Local<v8::String> name_str = v8_str(name, true);
|
||||
v8::Local<v8::String> source_str = v8_str(source, true);
|
||||
v8::Local<v8::String> name_str = v8_str(name);
|
||||
v8::Local<v8::String> source_str = v8_str(source);
|
||||
|
||||
auto origin = ModuleOrigin(isolate_, name_str);
|
||||
v8::ScriptCompiler::Source source_(source_str, origin);
|
||||
|
@ -341,8 +341,8 @@ bool Execute(v8::Local<v8::Context> context, const char* js_filename,
|
|||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
auto source = v8_str(js_source, true);
|
||||
auto name = v8_str(js_filename, true);
|
||||
auto source = v8_str(js_source);
|
||||
auto name = v8_str(js_filename);
|
||||
|
||||
v8::TryCatch try_catch(isolate);
|
||||
|
||||
|
@ -423,8 +423,7 @@ void HostInitializeImportMetaObjectCallback(v8::Local<v8::Context> context,
|
|||
|
||||
const char* url = info->name.c_str();
|
||||
|
||||
meta->CreateDataProperty(context, v8_str("url"), v8_str(url, true))
|
||||
.ToChecked();
|
||||
meta->CreateDataProperty(context, v8_str("url"), v8_str(url)).ToChecked();
|
||||
}
|
||||
|
||||
void DenoIsolate::AddIsolate(v8::Isolate* isolate) {
|
||||
|
|
|
@ -123,11 +123,9 @@ struct InternalFieldData {
|
|||
uint32_t data;
|
||||
};
|
||||
|
||||
static inline v8::Local<v8::String> v8_str(const char* x,
|
||||
bool internalize = false) {
|
||||
static inline v8::Local<v8::String> v8_str(const char* x) {
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x,
|
||||
internalize ? v8::NewStringType::kInternalized
|
||||
: v8::NewStringType::kNormal)
|
||||
v8::NewStringType::kNormal)
|
||||
.ToLocalChecked();
|
||||
}
|
||||
|
||||
|
|
|
@ -280,3 +280,12 @@ TEST(LibDenoTest, Shared) {
|
|||
EXPECT_EQ(s[2], 44);
|
||||
deno_delete(d);
|
||||
}
|
||||
|
||||
TEST(LibDenoTest, Utf8Bug) {
|
||||
Deno* d = deno_new(deno_config{0, empty, empty, nullptr});
|
||||
// The following is a valid UTF-8 javascript which just defines a string
|
||||
// literal. We had a bug where libdeno would choke on this.
|
||||
deno_execute(d, nullptr, "a.js", "x = \"\xEF\xBF\xBD\"");
|
||||
EXPECT_EQ(nullptr, deno_last_exception(d));
|
||||
deno_delete(d);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ v8::MaybeLocal<v8::Module> ResolveCallback(Local<Context> context,
|
|||
char buf[64 * 1024];
|
||||
snprintf(buf, sizeof(buf), "Cannot resolve module \"%s\" from \"%s\"",
|
||||
req_str.c_str(), referrer_info->name.c_str());
|
||||
isolate->ThrowException(deno::v8_str(buf, true));
|
||||
isolate->ThrowException(deno::v8_str(buf));
|
||||
break;
|
||||
} else {
|
||||
Local<Module> child_mod = info->handle.Get(isolate);
|
||||
|
|
Loading…
Reference in a new issue