Skip to content

Commit ee0a98b

Browse files
joyeecheungtargos
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 <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e879c5e commit ee0a98b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_errors.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ void OOMErrorHandler(const char* location, const v8::OOMDetails& details);
119119
std::string message = SPrintF(format, std::forward<Args>(args)...); \
120120
v8::Local<v8::String> js_code = OneByteString(isolate, #code); \
121121
v8::Local<v8::String> js_msg = \
122-
OneByteString(isolate, message.c_str(), message.length()); \
122+
v8::String::NewFromUtf8(isolate, \
123+
message.c_str(), \
124+
v8::NewStringType::kNormal, \
125+
message.length()) \
126+
.ToLocalChecked(); \
123127
v8::Local<v8::Object> e = v8::Exception::type(js_msg) \
124128
->ToObject(isolate->GetCurrentContext()) \
125129
.ToLocalChecked(); \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy