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 666217 - xsltproc does not return an error code if xinclude encounters parse errors.
xsltproc does not return an error code if xinclude encounters parse errors.
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
1.1.26
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2011-12-15 01:29 UTC by Malcolm Purvis
Modified: 2012-08-16 13:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test files (755 bytes, application/x-bzip2)
2011-12-15 01:29 UTC, Malcolm Purvis
  Details
Sample fix (739 bytes, patch)
2011-12-15 01:30 UTC, Malcolm Purvis
none Details | Review

Description Malcolm Purvis 2011-12-15 01:29:08 UTC
Created attachment 203530 [details]
Test files

When running xsltproc with the --xinclude option and if the included file contains parse errors, then xsltproc exits with a success return code (0) rather than an error code.  This is despite the fact that parser error messages are printed out.

This can be reproduced with using the attached tarball via the following steps:

------------------
$ tar -xf xinclude-error-code-bug.tar.bz2
$ cd xinclude-error-code-bug
$ xsltproc -o toc.xml --xinclude toc.xsl main.xhtml
include.xml:7: parser error : Opening and ending tag mismatch: p line 4 and div
</div>
      ^
include.xml:8: parser error : Premature end of data in tag div line 1

^
main.xhtml:8: element include: XInclude error : could not load include.xml, and no fallback was found

$ echo $?
0
$ 
---------

As a result the processing appears to complete successfully but the erroneous file is omitted from the output.  If run from a makefile, we have no indication that the output is wrong.

The problem seems to be that the return value of xmlXIncludeProcessFlags() is not checked for errors.  The attached patch solves the problem sufficiently for my needs, but since I'm not familiar with the code base I think that it needs more work before it is release quality.
Comment 1 Malcolm Purvis 2011-12-15 01:30:26 UTC
Created attachment 203532 [details] [review]
Sample fix
Comment 2 Daniel Veillard 2012-08-16 13:24:18 UTC
Looks good, applied nearly as-is, since it's an error in the
input document, error code should be 6 "error in documents" instead
of 9 "internal error"

  thanks a lot for the patch, pushed:

http://git.gnome.org/browse/libxslt/commit/?id=e669a8c7cefec93ee1bfaf59721aadc42e226d6e

Daniel