Hello libxml2 developers, TL/DR: ./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. File: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN³ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns=3D"http://www.w3.org/1999/xhtml"> <body> <div>test © </div> </body> </html> 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: stat("file:/usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd³, 0x7fff7f56fda0) = -1 ENOENT (No such file or directory) stat("file:/usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd³, 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: https://git.gnome.org/browse/libxml2/commit/?id=8eb55d782a2b9afacc793869489 1cc6fad7b42a5 https://git.gnome.org/browse/libxml2/commit/?id=beb7281055dbf0ed4d041022a67 c6c5cfd126f25 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 Matthias
Attachment:
patch.txt
Description: patch.txt