After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766834 - Validation errors for a valid XML with reader+XSD schema
Validation errors for a valid XML with reader+XSD schema
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-24 11:25 UTC by Shlomi Fish
Modified: 2017-01-05 10:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The reproducing test code and test cases in a tar.gz file. (12.74 KB, application/gzip)
2016-05-24 13:31 UTC, Shlomi Fish
  Details
[PATCH] Fix attribute decoding during XML schema validation (2.26 KB, patch)
2016-05-26 23:41 UTC, Alex Henrie
none Details | Review

Description Shlomi Fish 2016-05-24 11:25:42 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.
Comment 1 Daniel Veillard 2016-05-24 13:03:11 UTC
   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
Comment 2 Shlomi Fish 2016-05-24 13:31:25 UTC
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.
Comment 3 Shlomi Fish 2016-05-24 13:33:29 UTC
(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
Comment 4 Vladimír Čunát 2016-05-25 19:52:56 UTC
To me it seems strange that the error message claims that the partNum attribute is empty but that's clearly not true.
Comment 5 Vladimír Čunát 2016-05-26 11:41:16 UTC
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.)
Comment 6 Shlomi Fish 2016-05-26 13:16:51 UTC
(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?
Comment 7 Alex Henrie 2016-05-26 23:41:47 UTC
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.
Comment 8 Shlomi Fish 2016-05-27 07:06:46 UTC
(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).
Comment 9 Stefan Lundström 2016-08-29 06:53:50 UTC
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.
Comment 10 Daniel Veillard 2016-08-29 10:06:27 UTC
  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
Comment 11 Shlomi Fish 2016-08-29 10:17:44 UTC
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
Comment 12 Shlomi Fish 2016-09-02 10:58:28 UTC
(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.
Comment 13 David Kilzer 2017-01-05 10:12:33 UTC
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>