Unverified Commit eea3e57b authored by Milo Yip's avatar Milo Yip Committed by GitHub

Merge pull request #1416 from ylavic/regex_syntax_noassert

GenericRegex: don't throw/abort on syntax error (unclosed parenthesis).
parents 30d92a63 8c147873
...@@ -395,8 +395,7 @@ private: ...@@ -395,8 +395,7 @@ private:
} }
return false; return false;
default: case kOneOrMore:
RAPIDJSON_ASSERT(op == kOneOrMore);
if (operandStack.GetSize() >= sizeof(Frag)) { if (operandStack.GetSize() >= sizeof(Frag)) {
Frag e = *operandStack.template Pop<Frag>(1); Frag e = *operandStack.template Pop<Frag>(1);
SizeType s = NewState(kRegexInvalidState, e.start, 0); SizeType s = NewState(kRegexInvalidState, e.start, 0);
...@@ -405,6 +404,10 @@ private: ...@@ -405,6 +404,10 @@ private:
return true; return true;
} }
return false; return false;
default:
// syntax error (e.g. unclosed kLeftParenthesis)
return false;
} }
} }
......
...@@ -595,6 +595,7 @@ TEST(Regex, Invalid) { ...@@ -595,6 +595,7 @@ TEST(Regex, Invalid) {
TEST_INVALID(""); TEST_INVALID("");
TEST_INVALID("a|"); TEST_INVALID("a|");
TEST_INVALID("()"); TEST_INVALID("()");
TEST_INVALID("(");
TEST_INVALID(")"); TEST_INVALID(")");
TEST_INVALID("(a))"); TEST_INVALID("(a))");
TEST_INVALID("(a|)"); TEST_INVALID("(a|)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment