[libxml2] Problem with data in interleave in RelaxNG validation
- From: Daniel Veillard <veillard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Problem with data in interleave in RelaxNG validation
- Date: Thu, 22 Nov 2018 17:15:48 +0000 (UTC)
commit c8e5f9588b986c6e81c9028825aeff8151375d28
Author: Nikolai Weibull <now disu se>
Date: Thu Nov 22 18:09:51 2018 +0100
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.
relaxng.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/relaxng.c b/relaxng.c
index 88d351df..4be131d7 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -3979,7 +3979,7 @@ xmlRelaxNGGenerateAttributes(xmlRelaxNGParserCtxtPtr ctxt,
* xmlRelaxNGGetElements:
* @ctxt: a Relax-NG parser context
* @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
*
@@ -4005,7 +4005,12 @@ xmlRelaxNGGetElements(xmlRelaxNGParserCtxtPtr ctxt,
while (cur != NULL) {
if (((eora == 0) && ((cur->type == XML_RELAXNG_ELEMENT) ||
(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) {
max = 10;
ret = (xmlRelaxNGDefinePtr *)
@@ -4360,7 +4365,7 @@ xmlRelaxNGComputeInterleaves(void *payload, void *data,
if (cur->type == XML_RELAXNG_TEXT)
is_mixed++;
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);
nbgroups++;
cur = cur->next;
@@ -9262,7 +9267,10 @@ xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr * list)
return (1);
} else if (((node->type == XML_TEXT_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);
}
cur = list[i++];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]