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

Unified Diff: src/parser.cc

Issue 5703001: Revert 5911 (RegExp fail on invalid range syntax).
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 160f0f784489a409ab49d44b18edfc16dacdcc3b..fd93aae4241d7494dc26522ca4904081e746c4eb 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -4452,7 +4452,6 @@ CharacterRange RegExpParser::ParseClassAtom(uc16* char_class) {
RegExpTree* RegExpParser::ParseCharacterClass() {
static const char* kUnterminated = "Unterminated character class";
static const char* kRangeOutOfOrder = "Range out of order in character class";
- static const char* kInvalidRange = "Invalid character range";
ASSERT_EQ(current(), '[');
Advance();
@@ -4461,28 +4460,12 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
is_negated = true;
Advance();
}
- // A CharacterClass is a sequence of single characters, character class
- // escapes or ranges. Ranges are on the form "x-y" where x and y are
- // single characters (and not character class escapes like \s).
- // A "-" may occur at the start or end of the character class (just after
- // "[" or "[^", or just before "]") without being considered part of a
- // range. A "-" may also appear as the beginning or end of a range.
- // I.e., [--+] is valid, so is [!--].
-
ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
while (has_more() && current() != ']') {
uc16 char_class = 0;
CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED);
if (char_class) {
CharacterRange::AddClassEscape(char_class, ranges);
- if (current() == '-') {
- Advance();
- ranges->Add(CharacterRange::Singleton('-'));
- if (current() != ']') {
- ReportError(CStrVector(kInvalidRange) CHECK_FAILED);
- }
- break;
- }
continue;
}
if (current() == '-') {
@@ -4498,7 +4481,10 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
}
CharacterRange next = ParseClassAtom(&char_class CHECK_FAILED);
if (char_class) {
- ReportError(CStrVector(kInvalidRange) CHECK_FAILED);
+ ranges->Add(first);
+ ranges->Add(CharacterRange::Singleton('-'));
+ CharacterRange::AddClassEscape(char_class, ranges);
+ continue;
}
if (first.from() > next.to()) {
return ReportError(CStrVector(kRangeOutOfOrder) CHECK_FAILED);
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698