[xml] Problem resolving relative URIs during catalog resolution, potential regression as of libxml2 2.9.2 (patch included)

Hello libxml2 developers,


./testURI --base file:///some/where file

Without patch: file:/some/file
With patch: file:///some/file

Full report:

I am using PHP to read a simple XML file and see a regression between
libxml 2.9.1 and 2.9.2, with the problem still present in 2.9.4.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN³
<html xmlns=3D"http://www.w3.org/1999/xhtml";>
<div>test &copy; </div>

I am running this on Debian and have installed the w3c-dtd-xhtml pacakge,
relying on system tooling to generate the catalog definitions in /etc/xml.
If it helps, I can post a tarball with all relevant files from /etc/xml
and /usr/share/xml/xhtml somewhere.

The resulting catalog will contain file:///etc/... references to other
files, eventually pointing to file:///usr/share/xml/somewhere... and
finally contain relative references like 'uri="xhtml1-strict.dtd"'.

Due to a glitch in xmlBuildURI, interpreting this relative URI with a base
of "file:///usr/share/xml/xhtml/schema/dtd/1.0/catalog.xml" ends up as
"file:/usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd" with only a
single slash following the "file:".

Further down the road, this is interpreted as a file path and passed to
system calls, as can be seen in this strace output:

0x7fff7f56fda0) = -1 ENOENT (No such file or directory)
0x7fff7f56fd50) = -1 ENOENT (No such file or directory)

Immediately after, PHP fails with a PHP Notice: DOMDocument::loadXML():
failed to load external entity
"file:/usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd" in Entity,
line ...

The patch solves the problem for me.

Relevant changes:
Also see https://mail.gnome.org/archives/xml/2014-December/msg00000.html.

Please let me know if a test case for this is needed (would need
instructions how/where to write this).

Best regards

Attachment: patch.txt
Description: patch.txt

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]