1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

Fix empty branch in regex

Fixes bug 649244:
https://bugzilla.gnome.org/show_bug.cgi?id=649244

Closes #57.
This commit is contained in:
Nick Wellnhofer
2019-09-25 13:57:42 +02:00
parent 1fbcf4098b
commit c2b0a184a9
3 changed files with 25 additions and 7 deletions

View File

@ -5358,9 +5358,12 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
previous = ctxt->state;
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
if (ret == 0) {
/* Empty branch */
xmlFAGenerateEpsilonTransition(ctxt, previous, to);
} else {
if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
(CUR=='|' || CUR==')' || CUR==0) ? to : NULL, ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
ctxt->atom = NULL;
@ -5369,7 +5372,8 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
(CUR=='|' || CUR==')' || CUR==0) ? to : NULL,
ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
ctxt->atom = NULL;
@ -5406,10 +5410,6 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
end = ctxt->state;
while ((CUR == '|') && (ctxt->error == 0)) {
NEXT;
if (CUR == 0) {
ERROR("expecting a branch after |")
return;
}
ctxt->state = start;
ctxt->end = NULL;
xmlFAParseBranch(ctxt, end);