Merge pull request #1416 from ylavic/regex_syntax_noassert

GenericRegex: don't throw/abort on syntax error (unclosed parenthesis).
This commit is contained in:
Milo Yip 2018-12-06 23:41:45 +08:00 committed by GitHub
commit eea3e57bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -395,8 +395,7 @@ private:
}
return false;
default:
RAPIDJSON_ASSERT(op == kOneOrMore);
case kOneOrMore:
if (operandStack.GetSize() >= sizeof(Frag)) {
Frag e = *operandStack.template Pop<Frag>(1);
SizeType s = NewState(kRegexInvalidState, e.start, 0);
@ -405,6 +404,10 @@ private:
return true;
}
return false;
default:
// syntax error (e.g. unclosed kLeftParenthesis)
return false;
}
}

View File

@ -595,6 +595,7 @@ TEST(Regex, Invalid) {
TEST_INVALID("");
TEST_INVALID("a|");
TEST_INVALID("()");
TEST_INVALID("(");
TEST_INVALID(")");
TEST_INVALID("(a))");
TEST_INVALID("(a|)");