Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Unified Diff: src/regexp/regexp-parser.cc

Issue 2630233003: [regexp] Create property on result for each named capture (Closed)
Patch Set: Remove unused CaptureNameMapOffset Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {

Powered by Google App Engine
This is Rietveld 408576698