1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-12 09:17:37 +03:00

Fix unability to validate ambiguously constructed interleave for RelaxNG

Previously, test/relaxng/ambig_name-class.xml would fail to validate
for a simple reason -- interleave within "open-name-class" context
is supposed to be fine with whatever else is pending the consumption,
since effectively, it's unrelated from a higher parsing perspective.

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
This commit is contained in:
Jan Pokorný 2019-08-08 23:33:48 +02:00 committed by Nick Wellnhofer
parent 81958b6e94
commit 8074b88179
5 changed files with 29 additions and 1 deletions

View File

@ -9476,7 +9476,17 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGFreeValidState(ctxt, oldstate);
oldstate = ctxt->state;
ctxt->state = NULL;
if (cur != NULL) {
if (cur != NULL
/* there's a nasty violation of context-free unambiguities,
since in open-name-class context, interleave in the
production shall finish without caring about anything
else that is OK to follow in that case -- it would
otherwise get marked as "extra content" and would
hence fail the validation, hence this perhaps
dirty attempt to rectify such a situation */
&& (define->parent->type != XML_RELAXNG_DEF
|| !xmlStrEqual(define->parent->name,
(const xmlChar *) "open-name-class"))) {
VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
ret = -1;
ctxt->state = oldstate;

View File

@ -0,0 +1 @@
./test/relaxng/ambig_name-class.rng validates

View File

View File

@ -0,0 +1 @@
tutorA.rng

View File

@ -0,0 +1,16 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0" >
<start>
<element name="foo">
<attribute>
<choice>
<name>alpha</name>
<name>bravo</name>
</choice>
<choice>
<value>none</value>
<value>all</value>
</choice>
</attribute>
</element>
</start>
</grammar>