[libxml2] Fix unability to validate ambiguously constructed interleave for RelaxNG
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Fix unability to validate ambiguously constructed interleave for RelaxNG
- Date: Sun, 25 Aug 2019 12:32:44 +0000 (UTC)
commit 8074b881792b354b0e8c1b4076c5f41efd951a52
Author: Jan Pokorný <jpokorny redhat com>
Date: Thu Aug 8 23:33:48 2019 +0200
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>
relaxng.c | 12 +++++++++++-
result/relaxng/ambig_name-class_err | 1 +
result/relaxng/ambig_name-class_valid | 0
test/relaxng/ambig_name-class.rng | 1 +
test/relaxng/ambig_name-class.xml | 16 ++++++++++++++++
5 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/relaxng.c b/relaxng.c
index 2f13cbdd..1c337e3d 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -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;
diff --git a/result/relaxng/ambig_name-class_err b/result/relaxng/ambig_name-class_err
new file mode 100644
index 00000000..0afe5cd6
--- /dev/null
+++ b/result/relaxng/ambig_name-class_err
@@ -0,0 +1 @@
+./test/relaxng/ambig_name-class.rng validates
diff --git a/result/relaxng/ambig_name-class_valid b/result/relaxng/ambig_name-class_valid
new file mode 100644
index 00000000..e69de29b
diff --git a/test/relaxng/ambig_name-class.rng b/test/relaxng/ambig_name-class.rng
new file mode 120000
index 00000000..08533d39
--- /dev/null
+++ b/test/relaxng/ambig_name-class.rng
@@ -0,0 +1 @@
+tutorA.rng
\ No newline at end of file
diff --git a/test/relaxng/ambig_name-class.xml b/test/relaxng/ambig_name-class.xml
new file mode 100644
index 00000000..de673f2e
--- /dev/null
+++ b/test/relaxng/ambig_name-class.xml
@@ -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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]