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, ...@@ -332,7 +332,6 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
Handle<String> arg0, Handle<String> arg0,
Handle<String> arg1, Handle<String> arg1,
Handle<String> arg2) { Handle<String> arg2) {
static const int kMaxArgLength = 256;
Isolate* isolate = arg0->GetIsolate(); Isolate* isolate = arg0->GetIsolate();
const char* template_string; const char* template_string;
switch (template_index) { switch (template_index) {
...@@ -361,16 +360,7 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index, ...@@ -361,16 +360,7 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
} else { } else {
DCHECK(i < arraysize(args)); DCHECK(i < arraysize(args));
Handle<String> arg = args[i++]; Handle<String> arg = args[i++];
int length = arg->length(); builder.AppendString(arg);
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);
}
} }
} else { } else {
builder.AppendCharacter(*c); builder.AppendCharacter(*c);
......
...@@ -7553,6 +7553,22 @@ THREADED_TEST(ExceptionCreateMessage) { ...@@ -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, static void YGetter(Local<String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz(); 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