diff options
author | Rich Trott <rtrott@gmail.com> | 2022-03-11 08:51:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 08:51:41 +0300 |
commit | d8c4e375f21b8475d3b717d1d1120ad4eabf8f63 (patch) | |
tree | 06bae5d5131a154f6bb1b20947459969243e2959 /src/node_url.cc | |
parent | bf357b729501d42510b2bb65e9601c6e2947a428 (diff) |
url: preserve null char in WHATWG URL errors
A null character in the middle of an invalid URL was resulting in an
error message that truncated the input string. This preserves the entire
input string in the error message.
Refs: https://github.com/nodejs/node/issues/39592
PR-URL: https://github.com/nodejs/node/pull/42263
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_url.cc')
-rw-r--r-- | src/node_url.cc | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/node_url.cc b/src/node_url.cc index 59abbe43f99..79476e7a2f6 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -142,22 +142,12 @@ URLHost::~URLHost() { XX(ARG_FRAGMENT) \ XX(ARG_COUNT) // This one has to be last. -#define ERR_ARGS(XX) \ - XX(ERR_ARG_FLAGS) \ - XX(ERR_ARG_INPUT) \ - enum url_cb_args { #define XX(name) name, ARGS(XX) #undef XX }; -enum url_error_cb_args { -#define XX(name) name, - ERR_ARGS(XX) -#undef XX -}; - #define TWO_CHAR_STRING_TEST(bits, name, expr) \ template <typename T> \ bool name(const T ch1, const T ch2) { \ @@ -1679,12 +1669,8 @@ void Parse(Environment* env, SetArgs(env, argv, url); cb->Call(context, recv, arraysize(argv), argv).FromMaybe(Local<Value>()); } else if (error_cb->IsFunction()) { - Local<Value> argv[2] = { undef, undef }; - argv[ERR_ARG_FLAGS] = Integer::NewFromUnsigned(isolate, url.flags); - argv[ERR_ARG_INPUT] = - String::NewFromUtf8(env->isolate(), input).ToLocalChecked(); - error_cb.As<Function>()->Call(context, recv, arraysize(argv), argv) - .FromMaybe(Local<Value>()); + Local<Value> flags = Integer::NewFromUnsigned(isolate, url.flags); + USE(error_cb.As<Function>()->Call(context, recv, 1, &flags)); } } |