mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:03:19 +00:00
[vm/runtime] - Fix RegExp exception messages (issue 52691)
TEST=new test added Fixed: 52691 Change-Id: Ibc8865f8e9b1e908be80d4fbe8b8931eda448df8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312348 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
parent
a510e60dbf
commit
f84cf9413f
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "vm/longjump.h"
|
||||
#include "vm/object_store.h"
|
||||
#include "vm/symbols.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
@ -432,10 +433,16 @@ void RegExpParser::ReportError(const char* message) {
|
|||
next_pos_ = in().Length();
|
||||
|
||||
// Throw a FormatException on parsing failures.
|
||||
const String& msg = String::Handle(
|
||||
String::Concat(String::Handle(String::New(message)), in()));
|
||||
const Array& args = Array::Handle(Array::New(1));
|
||||
args.SetAt(0, msg);
|
||||
Array& args = Array::Handle();
|
||||
String& str = String::Handle();
|
||||
args ^= Array::New(3);
|
||||
str ^= String::New(message);
|
||||
args.SetAt(0, str);
|
||||
args.SetAt(1, Symbols::Blank());
|
||||
args.SetAt(2, in());
|
||||
str ^= String::ConcatAll(args);
|
||||
args ^= Array::New(1);
|
||||
args.SetAt(0, str);
|
||||
Exceptions::ThrowByType(Exceptions::kFormat, args);
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
|
10
tests/standalone/regress_52691_test.dart
Normal file
10
tests/standalone/regress_52691_test.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
import 'package:expect/expect.dart';
|
||||
|
||||
void main() {
|
||||
try {
|
||||
var re = RegExp(r'[c-');
|
||||
} on FormatException catch (e, s) {
|
||||
Expect.equals(
|
||||
"FormatException: Unterminated character class [c-", e.toString());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue