GNOME Bugzilla – Bug 766834
Validation errors for a valid XML with reader+XSD schema
Last modified: 2017-01-05 10:12:33 UTC
Hi all! Please see the test case at : https://github.com/shlomif/libxml2-2.9.4-reader-schema-regression it currently breaks the perl-XML-LibXML tests with 2.9.4 and works fine in 2.9.3. I am getting these validation errors: test/schema/demo.xml:1: Schemas validity error : Element 'Item', attribute 'partNum': [facet 'pattern'] The value '' is not accepted by the pattern '\d{3}-[A-Z]{2}'. test/schema/demo.xml:1: Schemas validity error : Element 'Item', attribute 'partNum': '' is not a valid value of the atomic type 'SKU'. test/schema/demo.xml:1: Schemas validity error : Element 'Item', attribute 'shipBy': [facet 'enumeration'] The value '' is not an element of the set {'air', 'land', 'any'}. test/schema/demo.xml:1: Schemas validity error : Element 'Item', attribute 'shipBy': '' is not a valid value of the local atomic type. xmllint agrees that the schema validates the XML. Please look into fixing it.
Hi, please add the reproducers to the bug, thanks ! Also I don't understand when you say that xmllint agree, you mean when not streaming ? you should be able to test XSD + the reader with xmllint, I think SAX and XSD should work too from xmllint. thanks, Daniel
Created attachment 328438 [details] The reproducing test code and test cases in a tar.gz file. This is the reproducing test case in a tarball.
(In reply to Daniel Veillard from comment #1) > Hi, > > please add the reproducers to the bug, thanks ! done. > Also I don't understand when you say that xmllint agree, you mean when > not streaming ? I used it like this: shlomif[XML-LibXML@]:$base/hg/bugs/libxml2-2.9.4-reader-xsd$ xmllint --schema test/schema/schema.xsd test/schema/demo.xml <?xml version="1.0"?> <Item partNum="926-AA" shipBy="air"> <productName>foo</productName> <quantity>2</quantity> <USPrice>1.0</USPrice> <comment>No comment !</comment> </Item> test/schema/demo.xml validates shlomif[XML-LibXML@]:$base/hg/bugs/libxml2-2.9.4-reader-xsd$ > you should be able to test XSD + the reader with xmllint, > I think SAX and XSD should work too from xmllint. I didn't try and don't know how. > > > thanks, > > Daniel
To me it seems strange that the error message claims that the partNum attribute is empty but that's clearly not true.
OK then, bisected to https://git.gnome.org/browse/libxml2/commit/?id=f6599c51648 Reverting that commit fixes the validation error. (I didn't try to truly understand the commit.)
(In reply to Vladimír Čunát from comment #5) > OK then, bisected to > https://git.gnome.org/browse/libxml2/commit/?id=f6599c51648 Reverting that > commit fixes the validation error. (I didn't try to truly understand the > commit.) Thanks for your help, Vladimir! Can someone remove the NEEDINFO status from this bug?
Created attachment 328604 [details] [review] [PATCH] Fix attribute decoding during XML schema validation I apologize for this regression. The problem is that vctxt->parserCtxt is always NULL in xmlSchemaSAXHandleStartElementNs, so this function can't call xmlStringLenDecodeEntities to decode the entities. Please try out the attached patch. I will send it to the mailing list also.
(In reply to Alex Henrie from comment #7) > Created attachment 328604 [details] [review] [review] > [PATCH] Fix attribute decoding during XML schema validation > > I apologize for this regression. The problem is that vctxt->parserCtxt is > always NULL in xmlSchemaSAXHandleStartElementNs, so this function can't call > xmlStringLenDecodeEntities to decode the entities. > > Please try out the attached patch. I will send it to the mailing list also. Thanks, Alex! I tested the patch and it seems to fix my test case as well as perl-XML-LibXML’s test suite. I think you should also write a regression test for it as part of libxml2's core test suite (to avoid future breakages).
This issue seems misstagged as NEEDINFO? It's been sitting for 3 months now. Simplest of schema validations seems to break with this regression so I think it warrents another release. Several distributions have updated to 2.9.4 as it was labeled a security patch.
Hey Alex, thanks for the patch, that makes sense, so apllied and commited : https://git.gnome.org/browse/libxml2/commit/?id=3169602058bd2d04913909e869c61d1540bc7fb4 Shlomi, thanks for the report ! Daniel
Hi Daniel! (In reply to Daniel Veillard from comment #10) > Hey Alex, > > thanks for the patch, that makes sense, so apllied and commited : > > https://git.gnome.org/browse/libxml2/commit/ > ?id=3169602058bd2d04913909e869c61d1540bc7fb4 > > Shlomi, thanks for the report ! > You're welcome and - thanks! But wait: did you also add an automated regression test for this issue in libxml2's test suite per my suggestion in https://bugzilla.gnome.org/show_bug.cgi?id=766834#c8 ? Otherwise, the problematic behaviour may be re-introduced and there are going to be more breakages in the future. Regards, -- Shlomi Fish
(In reply to Shlomi Fish from comment #11) > Hi Daniel! > > (In reply to Daniel Veillard from comment #10) > > Hey Alex, > > > > thanks for the patch, that makes sense, so apllied and commited : > > > > https://git.gnome.org/browse/libxml2/commit/ > > ?id=3169602058bd2d04913909e869c61d1540bc7fb4 > > > > Shlomi, thanks for the report ! > > > > You're welcome and - thanks! But wait: did you also add an automated > regression test for this issue in libxml2's test suite per my suggestion in > https://bugzilla.gnome.org/show_bug.cgi?id=766834#c8 ? Otherwise, the > problematic behaviour may be re-introduced and there are going to be more > breakages in the future. > > Regards, > > -- Shlomi Fish Reopening due to lack of responsiveness.
Let's move this back to RESOLVED/FIXED, and track adding tests here: Bug 776895: Add "Schemas streaming regression tests" to runtest in libxml2 <https://bugzilla.gnome.org/show_bug.cgi?id=776895>