1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

Problem with data in interleave in RelaxNG validation

Reported in https://mail.gnome.org/archives/xml/2018-October/msg00003.html

The issue seems to be that we build groups of what can be matched by
the interleave, but that these groups don’t include data, list,
and value elements, only element and text elements.  This patch
extends xmlRelaxNGGetElements so that it can return these elements
for us in xmlRelaxNGComputeInterleaves.  Then we make sure to
updatexmlRelaxNGNodeMatchesList as well so that it accepts the correct
types.
This commit is contained in:
Nikolai Weibull 2018-11-22 18:09:51 +01:00 committed by Daniel Veillard
parent 3776cb4745
commit c8e5f9588b

View File

@ -3979,7 +3979,7 @@ xmlRelaxNGGenerateAttributes(xmlRelaxNGParserCtxtPtr ctxt,
* xmlRelaxNGGetElements: * xmlRelaxNGGetElements:
* @ctxt: a Relax-NG parser context * @ctxt: a Relax-NG parser context
* @def: the definition definition * @def: the definition definition
* @eora: gather elements (0) or attributes (1) * @eora: gather elements (0), attributes (1) or elements and text (2)
* *
* Compute the list of top elements a definition can generate * Compute the list of top elements a definition can generate
* *
@ -4005,7 +4005,12 @@ xmlRelaxNGGetElements(xmlRelaxNGParserCtxtPtr ctxt,
while (cur != NULL) { while (cur != NULL) {
if (((eora == 0) && ((cur->type == XML_RELAXNG_ELEMENT) || if (((eora == 0) && ((cur->type == XML_RELAXNG_ELEMENT) ||
(cur->type == XML_RELAXNG_TEXT))) || (cur->type == XML_RELAXNG_TEXT))) ||
((eora == 1) && (cur->type == XML_RELAXNG_ATTRIBUTE))) { ((eora == 1) && (cur->type == XML_RELAXNG_ATTRIBUTE)) ||
((eora == 2) && ((cur->type == XML_RELAXNG_DATATYPE) ||
(cur->type == XML_RELAXNG_ELEMENT) ||
(cur->type == XML_RELAXNG_LIST) ||
(cur->type == XML_RELAXNG_VALUE)))) {
if (ret == NULL) { if (ret == NULL) {
max = 10; max = 10;
ret = (xmlRelaxNGDefinePtr *) ret = (xmlRelaxNGDefinePtr *)
@ -4360,7 +4365,7 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
if (cur->type == XML_RELAXNG_TEXT) if (cur->type == XML_RELAXNG_TEXT)
is_mixed++; is_mixed++;
groups[nbgroups]->rule = cur; groups[nbgroups]->rule = cur;
groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 0); groups[nbgroups]->defs = xmlRelaxNGGetElements(ctxt, cur, 2);
groups[nbgroups]->attrs = xmlRelaxNGGetElements(ctxt, cur, 1); groups[nbgroups]->attrs = xmlRelaxNGGetElements(ctxt, cur, 1);
nbgroups++; nbgroups++;
cur = cur->next; cur = cur->next;
@ -9262,7 +9267,10 @@ xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr * list)
return (1); return (1);
} else if (((node->type == XML_TEXT_NODE) || } else if (((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) && (node->type == XML_CDATA_SECTION_NODE)) &&
(cur->type == XML_RELAXNG_TEXT)) { ((cur->type == XML_RELAXNG_TEXT) ||
(cur->type == XML_RELAXNG_DATATYPE) ||
(cur->type == XML_RELAXNG_LIST) ||
(cur->type == XML_RELAXNG_VALUE))) {
return (1); return (1);
} }
cur = list[i++]; cur = list[i++];