Skip to content

Commit df1f049

Browse files
joyeecheungmarco-ippolito
authored andcommitted
src: decode native error messages as UTF-8
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]>
1 parent 7802170 commit df1f049

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_errors.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
112112
std::string message = SPrintF(format, std::forward<Args>(args)...); \
113113
v8::Local<v8::String> js_code = OneByteString(isolate, #code); \
114114
v8::Local<v8::String> js_msg = \
115-
OneByteString(isolate, message.c_str(), message.length()); \
115+
v8::String::NewFromUtf8(isolate, \
116+
message.c_str(), \
117+
v8::NewStringType::kNormal, \
118+
message.length()) \
119+
.ToLocalChecked(); \
116120
v8::Local<v8::Object> e = v8::Exception::type(js_msg) \
117121
->ToObject(isolate->GetCurrentContext()) \
118122
.ToLocalChecked(); \

0 commit comments

Comments
 (0)