Commit f7b0ee34 authored by yangguo's avatar yangguo Committed by Commit bot

Do not truncate message strings.

R=ishell@chromium.org
BUG=chromium:505539
LOG=N

Review URL: https://codereview.chromium.org/1214373005

Cr-Commit-Position: refs/heads/master@{#29481}
parent 9e71cdba
......@@ -332,7 +332,6 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
Handle<String> arg0,
Handle<String> arg1,
Handle<String> arg2) {
static const int kMaxArgLength = 256;
Isolate* isolate = arg0->GetIsolate();
const char* template_string;
switch (template_index) {
......@@ -361,16 +360,7 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
} else {
DCHECK(i < arraysize(args));
Handle<String> arg = args[i++];
int length = arg->length();
if (length > kMaxArgLength) {
builder.AppendString(
isolate->factory()->NewSubString(arg, 0, kMaxArgLength - 6));
builder.AppendCString("...");
builder.AppendString(
isolate->factory()->NewSubString(arg, length - 3, length));
} else {
builder.AppendString(arg);
}
builder.AppendString(arg);
}
} else {
builder.AppendCharacter(*c);
......
......@@ -7553,6 +7553,22 @@ THREADED_TEST(ExceptionCreateMessage) {
}
THREADED_TEST(ExceptionCreateMessageLength) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
// Test that the message is not truncated.
TryCatch try_catch(context->GetIsolate());
CompileRun(
"var message = 'm';"
"while (message.length < 1000) message += message;"
"throw message;");
CHECK(try_catch.HasCaught());
CHECK_LT(1000, try_catch.Message()->Get()->Length());
}
static void YGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment