1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +03:00

enhanced xmlFARegExec range evaluation for min occurs 0 problems - fixes

* xmlregexp.c: enhanced xmlFARegExec range evaluation for min
  occurs 0 problems - fixes bug 140478.
This commit is contained in:
William M. Brack
2004-04-26 15:40:47 +00:00
parent f762755fd7
commit 0e00b28db6
2 changed files with 36 additions and 5 deletions

View File

@ -1,3 +1,8 @@
Mon Apr 26 23:37:12 HKT 2004 William Brack <wbrack@mmm.com.hk>
* xmlregexp.c: enhanced xmlFARegExec range evaluation for min
occurs 0 problems - fixes bug 140478.
Thu Apr 22 09:12:47 CEST 2004 Daniel Veillard <daniel@veillard.com> Thu Apr 22 09:12:47 CEST 2004 Daniel Veillard <daniel@veillard.com>
* rngparser.c: tiny path fixes the "xmlConvertCRNGFile" function name * rngparser.c: tiny path fixes the "xmlConvertCRNGFile" function name

View File

@ -2235,12 +2235,24 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
xmlRegAtomPtr atom; xmlRegAtomPtr atom;
/* /*
* End of input on non-terminal state, rollback, however we may * If end of input on non-terminal state, rollback, however we may
* still have epsilon like transition for counted transitions * still have epsilon like transition for counted transitions
* on counters, in that case don't break too early. * on counters, in that case don't break too early. Additionally,
* if we are working on a range like "AB{0,2}", where B is not present,
* we don't want to break.
*/ */
if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) if ((exec->inputString[exec->index] == 0) && (exec->counts == NULL)) {
goto rollback; /* must check if atom allows minOccurs of 0 */
if (exec->transno < exec->state->nbTrans) { /* there is a transition */
trans = &exec->state->trans[exec->transno];
if (trans->to >=0) {
atom = trans->atom;
if (!((atom->min == 0) && (atom->max > 0)))
goto rollback;
}
} else
goto rollback;
}
exec->transcount = 0; exec->transcount = 0;
for (;exec->transno < exec->state->nbTrans;exec->transno++) { for (;exec->transno < exec->state->nbTrans;exec->transno++) {
@ -2271,7 +2283,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
} else if (exec->inputString[exec->index] != 0) { } else if (exec->inputString[exec->index] != 0) {
codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len); codepoint = CUR_SCHAR(&(exec->inputString[exec->index]), len);
ret = xmlRegCheckCharacter(atom, codepoint); ret = xmlRegCheckCharacter(atom, codepoint);
if ((ret == 1) && (atom->min > 0) && (atom->max > 0)) { if ((ret == 1) && (atom->min >= 0) && (atom->max > 0)) {
xmlRegStatePtr to = comp->states[trans->to]; xmlRegStatePtr to = comp->states[trans->to];
/* /*
@ -2326,7 +2338,21 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
if (ret == 0) { if (ret == 0) {
goto rollback; goto rollback;
} }
} else if ((ret == 0) && (atom->min == 0) && (atom->max > 0)) {
/*
* we don't match on the codepoint, but minOccurs of 0
* says that's ok. Setting len to 0 inhibits stepping
* over the codepoint.
*/
exec->transcount = 1;
len = 0;
ret = 1;
} }
} else if ((atom->min == 0) && (atom->max > 0)) {
/* another spot to match when minOccurs is 0 */
exec->transcount = 1;
len = 0;
ret = 1;
} }
if (ret == 1) { if (ret == 1) {
if (exec->state->nbTrans > exec->transno + 1) { if (exec->state->nbTrans > exec->transno + 1) {