Merge pull request #1416 from ylavic/regex_syntax_noassert
GenericRegex: don't throw/abort on syntax error (unclosed parenthesis).
This commit is contained in:
commit
eea3e57bcf
@ -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:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// syntax error (e.g. unclosed kLeftParenthesis)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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|)");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user