Index: src/regexp/regexp-parser.cc |
diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc |
index 3035f6a9a953e6eb5ffe4466e07612f27b6c9996..cbfa80dcf0e0e46374714c8dfd5fc7c70da94a99 100644 |
--- a/src/regexp/regexp-parser.cc |
+++ b/src/regexp/regexp-parser.cc |
@@ -768,6 +768,26 @@ bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name, |
DCHECK(0 < index && index <= captures_started_); |
DCHECK_NOT_NULL(name); |
+ static std::vector<uc16> illegal_names[] = { |
+ { |
+ 'i', 'n', 'd', 'e', 'x', |
Yang
2017/01/18 13:25:36
Is it possible to use wide string literals here? h
jgruber
2017/01/19 15:59:12
I didn't find a way to do that for this use case.
|
+ }, |
+ { |
+ 'i', 'n', 'p', 'u', 't', |
+ }, |
+ { |
+ 'l', 'e', 'n', 'g', 't', 'h', |
+ }, |
+ }; |
+ |
+ for (const auto& illegal_name : illegal_names) { |
+ if (name->size() != illegal_name.size()) continue; |
+ if (std::equal(name->begin(), name->end(), illegal_name.begin())) { |
+ ReportError(CStrVector("Illegal capture group name")); |
+ return false; |
+ } |
+ } |
+ |
if (named_captures_ == nullptr) { |
named_captures_ = new (zone()) ZoneList<RegExpCapture*>(1, zone()); |
} else { |