1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-23 01:52:48 +03:00

xmlValidatePopElement() can return invalid value (-1)

Covered by:  test/VC/ElementValid5

This only affects XML Reader API with LIBXML_REGEXP_ENABLED and
LIBXML_VALID_ENABLED turned on.

* result/VC/ElementValid5.rdr:
- Update result to add missing error message.

* python/tests/reader2.py:
* result/VC/ElementValid6.rdr:
* result/VC/ElementValid7.rdr:
* result/valid/781333.xml.err.rdr:
- Update result to fix grammar issue.

* valid.c:
(xmlValidatePopElement):
- Check return value of xmlRegExecPushString() to handle -1, and
  assign 'ret = 0;' to return 0 from xmlValidatePopElement().
  This change affects xmlTextReaderValidatePop() from
  xmlreader.c.
- Fix grammar of error message by changing 'child' to
  'children'.
This commit is contained in:
David Kilzer
2023-04-10 13:06:18 -07:00
parent d7d0bc6581
commit cb1b8b8516
6 changed files with 10 additions and 6 deletions

View File

@@ -41,7 +41,7 @@ value
"""{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got """{0}/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got
<a/> <a/>
^ ^
{0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child {0}/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
^ ^
""".format(dir_prefix), """.format(dir_prefix),

View File

@@ -4,3 +4,6 @@
./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Misplaced b ./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Misplaced b
^ ^
./test/VC/ElementValid5:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
^

View File

@@ -1,6 +1,6 @@
./test/VC/ElementValid6:7: element doc: validity error : Element doc content does not follow the DTD, expecting (a , b? , c+)?, got (a b) ./test/VC/ElementValid6:7: element doc: validity error : Element doc content does not follow the DTD, expecting (a , b? , c+)?, got (a b)
<doc><a/><b>lacks c</b></doc> <doc><a/><b>lacks c</b></doc>
^ ^
./test/VC/ElementValid6:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more child ./test/VC/ElementValid6:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
^ ^

View File

@@ -1,6 +1,6 @@
./test/VC/ElementValid7:7: element doc: validity error : Element doc content does not follow the DTD, expecting ((a | b)* , c+ , a , b? , c , a?), got (a b a c c a) ./test/VC/ElementValid7:7: element doc: validity error : Element doc content does not follow the DTD, expecting ((a | b)* , c+ , a , b? , c , a?), got (a b a c c a)
<doc><a/><b/><a/><c/><c/><a/></doc> <doc><a/><b/><a/><c/><c/><a/></doc>
^ ^
./test/VC/ElementValid7:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more child ./test/VC/ElementValid7:8: element doc: validity error : Element doc content does not follow the DTD, Expecting more children
^ ^

View File

@@ -1,6 +1,6 @@
./test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got ./test/valid/781333.xml:4: element a: validity error : Element a content does not follow the DTD, expecting ( ..., got
<a/> <a/>
^ ^
./test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more child ./test/valid/781333.xml:5: element a: validity error : Element a content does not follow the DTD, Expecting more children
^ ^

View File

@@ -5999,11 +5999,12 @@ xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED,
if (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT) { if (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT) {
if (state->exec != NULL) { if (state->exec != NULL) {
ret = xmlRegExecPushString(state->exec, NULL, NULL); ret = xmlRegExecPushString(state->exec, NULL, NULL);
if (ret == 0) { if (ret <= 0) {
xmlErrValidNode(ctxt, state->node, xmlErrValidNode(ctxt, state->node,
XML_DTD_CONTENT_MODEL, XML_DTD_CONTENT_MODEL,
"Element %s content does not follow the DTD, Expecting more child\n", "Element %s content does not follow the DTD, Expecting more children\n",
state->node->name, NULL,NULL); state->node->name, NULL,NULL);
ret = 0;
} else { } else {
/* /*
* previous validation errors should not generate * previous validation errors should not generate