Under certain circumstances a CharRef is resolved twice which leads
to a wrong interpretation of some regular expressions in XML Schemas.
The attached patch fixes this bug by removing some superfluous code
and adding appropriate unit tests. In addition to this patch, you
need to create two empty files:
touch result/schemas/regexp-char-ref_0_0.err
touch result/schemas/regexp-char-ref_1_0.err
More details: http://bugzilla.gnome.org/show_bug.cgi?id=542666
Greets,
Volker
--
Volker Grabsch
---<<(())>>---
Administrator
NotJustHosting GbR
http://bugzilla.gnome.org/show_bug.cgi?id=542666
In addition to this patch, you need to create some empty files:
touch result/schemas/regexp-char-ref_0_0.err
touch result/schemas/regexp-char-ref_1_0.err
Index: libxml2-svn/xmlregexp.c
===================================================================
--- libxml2-svn/xmlregexp.c (Revision 3751)
+++ libxml2-svn/xmlregexp.c (Arbeitskopie)
@@ -4907,64 +4907,6 @@
}
/**
- * xmlFAParseCharRef:
- * @ctxt: a regexp parser context
- *
- * [19] XmlCharRef ::= ( '&#' [0-9]+ ';' ) | (' &#x' [0-9a-fA-F]+ ';' )
- */
-static int
-xmlFAParseCharRef(xmlRegParserCtxtPtr ctxt) {
- int ret = 0, cur;
-
- if ((CUR != '&') || (NXT(1) != '#'))
- return(-1);
- NEXT;
- NEXT;
- cur = CUR;
- if (cur == 'x') {
- NEXT;
- cur = CUR;
- if (((cur >= '0') && (cur <= '9')) ||
- ((cur >= 'a') && (cur <= 'f')) ||
- ((cur >= 'A') && (cur <= 'F'))) {
- while (((cur >= '0') && (cur <= '9')) ||
- ((cur >= 'a') && (cur <= 'f')) ||
- ((cur >= 'A') && (cur <= 'F'))) {
- if ((cur >= '0') && (cur <= '9'))
- ret = ret * 16 + cur - '0';
- else if ((cur >= 'a') && (cur <= 'f'))
- ret = ret * 16 + 10 + (cur - 'a');
- else
- ret = ret * 16 + 10 + (cur - 'A');
- NEXT;
- cur = CUR;
- }
- } else {
- ERROR("Char ref: expecting [0-9A-F]");
- return(-1);
- }
- } else {
- if ((cur >= '0') && (cur <= '9')) {
- while ((cur >= '0') && (cur <= '9')) {
- ret = ret * 10 + cur - '0';
- NEXT;
- cur = CUR;
- }
- } else {
- ERROR("Char ref: expecting [0-9]");
- return(-1);
- }
- }
- if (cur != ';') {
- ERROR("Char ref: expecting ';'");
- return(-1);
- } else {
- NEXT;
- }
- return(ret);
-}
-
-/**
* xmlFAParseCharRange:
* @ctxt: a regexp parser context
*
@@ -4985,12 +4927,6 @@
return;
}
- if ((CUR == '&') && (NXT(1) == '#')) {
- end = start = xmlFAParseCharRef(ctxt);
- xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
- XML_REGEXP_CHARVAL, start, end, NULL);
- return;
- }
cur = CUR;
if (cur == '\\') {
NEXT;
Index: libxml2-svn/result/schemas/regexp-char-ref_0_0.err
===================================================================
Index: libxml2-svn/result/schemas/regexp-char-ref_1_0.err
===================================================================
Index: libxml2-svn/result/schemas/regexp-char-ref_0_0
===================================================================
--- libxml2-svn/result/schemas/regexp-char-ref_0_0 (Revision 0)
+++ libxml2-svn/result/schemas/regexp-char-ref_0_0 (Revision 0)
@@ -0,0 +1 @@
+./test/schemas/regexp-char-ref_0.xml validates
Index: libxml2-svn/result/schemas/regexp-char-ref_1_0
===================================================================
--- libxml2-svn/result/schemas/regexp-char-ref_1_0 (Revision 0)
+++ libxml2-svn/result/schemas/regexp-char-ref_1_0 (Revision 0)
@@ -0,0 +1 @@
+./test/schemas/regexp-char-ref_0.xml validates
Index: libxml2-svn/test/schemas/regexp-char-ref_0.xml
===================================================================
--- libxml2-svn/test/schemas/regexp-char-ref_0.xml (Revision 0)
+++ libxml2-svn/test/schemas/regexp-char-ref_0.xml (Revision 0)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+
+<test test1="5"
+ test2="6"
+ test3="#"
+ test4=";"
+ test5="&" />
Index: libxml2-svn/test/schemas/regexp-char-ref_0.xsd
===================================================================
--- libxml2-svn/test/schemas/regexp-char-ref_0.xsd (Revision 0)
+++ libxml2-svn/test/schemas/regexp-char-ref_0.xsd (Revision 0)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="test">
+ <xs:complexType>
+ <xs:attribute name="test1" type="myType"/>
+ <xs:attribute name="test2" type="myType"/>
+ <xs:attribute name="test3" type="myType"/>
+ <xs:attribute name="test4" type="myType"/>
+ <xs:attribute name="test5" type="myType"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:simpleType name="myType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[56;&#]"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
Index: libxml2-svn/test/schemas/regexp-char-ref_1.xsd
===================================================================
--- libxml2-svn/test/schemas/regexp-char-ref_1.xsd (Revision 0)
+++ libxml2-svn/test/schemas/regexp-char-ref_1.xsd (Revision 0)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="test">
+ <xs:complexType>
+ <xs:attribute name="test1" type="myType"/>
+ <xs:attribute name="test2" type="myType"/>
+ <xs:attribute name="test3" type="myType"/>
+ <xs:attribute name="test4" type="myType"/>
+ <xs:attribute name="test5" type="myType"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:simpleType name="myType">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[&#65;]"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+</xs:schema>
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml