-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT LAND] src: invalidate Utf8/TwoByteValue upon error #11952
Changes from all commits
dd40f5a
e47b0d3
360cbae
af4f5f0
27e49e0
a7857a0
b5df96f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ using v8::Value; | |
{ \ | ||
Local<Value> val = GET(env, obj, #name); \ | ||
if (val->IsString()) { \ | ||
Utf8Value value(env->isolate(), val.As<String>()); \ | ||
Utf8Value value(env->isolate(), val); \ | ||
CHECK(!value.IsInvalidated()); \ | ||
data->name = *value; \ | ||
data->flags |= flag; \ | ||
} \ | ||
|
@@ -509,7 +510,8 @@ namespace url { | |
for (int32_t n = 0; n < len; n++) { | ||
Local<Value> val = ary->Get(env->context(), n).ToLocalChecked(); | ||
if (val->IsString()) { | ||
Utf8Value value(env->isolate(), val.As<String>()); | ||
Utf8Value value(env->isolate(), val); | ||
CHECK(!value.IsInvalidated()); | ||
vec->push_back(std::string(*value, value.length())); | ||
} | ||
} | ||
|
@@ -562,6 +564,7 @@ namespace url { | |
Local<Value> scheme = GET(env, context_obj, "scheme"); | ||
if (scheme->IsString()) { | ||
Utf8Value value(env->isolate(), scheme); | ||
CHECK(!value.IsInvalidated()); | ||
context->scheme.assign(*value, value.length()); | ||
} | ||
Local<Value> port = GET(env, context_obj, "port"); | ||
|
@@ -1297,7 +1300,6 @@ namespace url { | |
static void Parse(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
CHECK_GE(args.Length(), 5); | ||
CHECK(args[0]->IsString()); | ||
CHECK(args[2]->IsUndefined() || | ||
args[2]->IsNull() || | ||
args[2]->IsObject()); | ||
|
@@ -1306,6 +1308,7 @@ namespace url { | |
args[3]->IsObject()); | ||
CHECK(args[4]->IsFunction()); | ||
Utf8Value input(env->isolate(), args[0]); | ||
CHECK(!input.IsInvalidated()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you remove the ditto for the remainder of the file (or am I missing something here?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll return in this and some other cases, but there are instances where |
||
enum url_parse_state state_override = kUnknownState; | ||
if (args[1]->IsNumber()) { | ||
state_override = static_cast<enum url_parse_state>( | ||
|
@@ -1323,8 +1326,8 @@ namespace url { | |
static void EncodeAuthSet(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
CHECK_GE(args.Length(), 1); | ||
CHECK(args[0]->IsString()); | ||
Utf8Value value(env->isolate(), args[0]); | ||
CHECK(!value.IsInvalidated()); | ||
std::string output; | ||
const size_t len = value.length(); | ||
output.reserve(len); | ||
|
@@ -1341,10 +1344,10 @@ namespace url { | |
static void ToUSVString(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
CHECK_GE(args.Length(), 2); | ||
CHECK(args[0]->IsString()); | ||
CHECK(args[1]->IsNumber()); | ||
|
||
TwoByteValue value(env->isolate(), args[0]); | ||
CHECK(!value.IsInvalidated()); | ||
const size_t n = value.length(); | ||
|
||
const int64_t start = args[1]->IntegerValue(env->context()).FromJust(); | ||
|
@@ -1376,8 +1379,8 @@ namespace url { | |
static void DomainToASCII(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
CHECK_GE(args.Length(), 1); | ||
CHECK(args[0]->IsString()); | ||
Utf8Value value(env->isolate(), args[0]); | ||
CHECK(!value.IsInvalidated()); | ||
|
||
url_host host{{""}, HOST_TYPE_DOMAIN}; | ||
ParseHost(&host, *value, value.length()); | ||
|
@@ -1396,8 +1399,8 @@ namespace url { | |
static void DomainToUnicode(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
CHECK_GE(args.Length(), 1); | ||
CHECK(args[0]->IsString()); | ||
Utf8Value value(env->isolate(), args[0]); | ||
CHECK(!value.IsInvalidated()); | ||
|
||
url_host host{{""}, HOST_TYPE_DOMAIN}; | ||
ParseHost(&host, *value, value.length(), true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just
args[i] += '';
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That calls
args[i][Symbol.toPrimitive]()
(if there is one) with'default'
instead of'string'
, thus breaking compatibility.