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

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

Issue 2630233003: [regexp] Create property on result for each named capture (Closed)
Patch Set: Rebase 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 3621f7d96e4fbf4634b7a214d7beb5defa019eae..ebaccc5588c335ca17e1b9df0003146a42f2ecdf 100644
--- a/src/regexp/regexp-parser.cc
+++ b/src/regexp/regexp-parser.cc
@@ -770,6 +770,15 @@ bool RegExpParser::CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name,
DCHECK(0 < index && index <= captures_started_);
DCHECK_NOT_NULL(name);
+ // Disallow captures named '__proto__'.
+ static const char16_t proto_string[] = u"__proto__";
Dan Ehrenberg 2017/01/20 18:23:46 Sorry I didn't post this comment earlier, but: If
+ if (name->size() == arraysize(proto_string) - 1) {
+ if (std::equal(name->begin(), name->end(), &proto_string[0])) {
+ 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