Skip to content

Commit

Permalink
src: decode native error messages as UTF-8
Browse files Browse the repository at this point in the history
The native error messages can sometimes contain e.g. path content
that are typically passed in as chars with UTF8-encoded code points.
The native error throwing code previously always decode the chars
as Latin-1, which would be incorrect.

PR-URL: #55024
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and marco-ippolito committed Nov 17, 2024
1 parent 7802170 commit df1f049
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
std::string message = SPrintF(format, std::forward<Args>(args)...); \
v8::Local<v8::String> js_code = OneByteString(isolate, #code); \
v8::Local<v8::String> js_msg = \
OneByteString(isolate, message.c_str(), message.length()); \
v8::String::NewFromUtf8(isolate, \
message.c_str(), \
v8::NewStringType::kNormal, \
message.length()) \
.ToLocalChecked(); \
v8::Local<v8::Object> e = v8::Exception::type(js_msg) \
->ToObject(isolate->GetCurrentContext()) \
.ToLocalChecked(); \
Expand Down

0 comments on commit df1f049

Please sign in to comment.