diff --git a/src/messages.cc b/src/messages.cc index 5e050bd290..7193392d9d 100644 --- a/src/messages.cc +++ b/src/messages.cc @@ -332,7 +332,6 @@ MaybeHandle MessageTemplate::FormatMessage(int template_index, Handle arg0, Handle arg1, Handle arg2) { - static const int kMaxArgLength = 256; Isolate* isolate = arg0->GetIsolate(); const char* template_string; switch (template_index) { @@ -361,16 +360,7 @@ MaybeHandle MessageTemplate::FormatMessage(int template_index, } else { DCHECK(i < arraysize(args)); Handle 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); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 49ee96988d..357b8b2448 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -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 name, const v8::PropertyCallbackInfo& info) { ApiTestFuzzer::Fuzz();