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: nodejs#55024
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and tpoisseau committed Nov 21, 2024
1 parent e73d4d1 commit 17e65c3
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 @@ -119,7 +119,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 17e65c3

Please sign in to comment.