GNOME Bugzilla – Bug 611342
catalog from oasis-xml-catalog PI is freed immediately
Last modified: 2021-07-05 13:26:25 UTC
Created attachment 154875 [details] test suite It looks like when the <?oasis-xml-catalog catalog="..."?> PI is used, the catalog it points to is freed too soon to do anything. Below is my main file, it wants to include another, located in a different directory: <?xml version="1.0" encoding="UTF-8"?> <?oasis-xml-catalog catalog="./catalog.xml"?> <text xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="header.xml"/> <p>some stuff here</p> </text> The redirect is supposed to take place via a catalog file with the line: <system systemId="header.xml" uri="level1/header.xml"/> but that does not happen when the PI is used: $ xmllint --noout --xinclude text.xml Adding document catalog ./catalog.xml Free catalog entry ./catalog.xml <---------- note this Resolve: sysID header.xml Failed to parse catalog file:///etc/xml/catalog Resolve URI header.xml warning: failed to load external entity "header.xml" text.xml:4: element include: XInclude error : could not load header.xml, and no fallback was found Catalogs cleanup Free catalog entry But the xmlcatalog has no problem locating the file via the same catalog: $ xmlcatalog --shell ./catalog.xml > system header.xml Resolve sysID header.xml 7012456 Parsing catalog ./catalog.xml ./catalog.xml added to file hash Found system match header.xml, using level1/header.xml level1/header.xml > dump <?xml version="1.0"?> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <system systemId="header.xml" uri="level1/header.xml"/> </catalog> > exit Catalogs cleanup Free catalog entry header.xml Free catalog entry ./catalog.xml <---------- note this Free catalog entry For the sake of completeness, here is the nearly-expected output -- except I had to use the default catalog in /etc/xml/ to point to the one in the test suite (via nextCatalog): $ xmllint --xinclude text.xml Adding document catalog ./catalog.xml Free catalog entry ./catalog.xml <---------- note this, again Resolve: sysID header.xml 7077992 Parsing catalog file:///etc/xml/catalog file:///etc/xml/catalog added to file hash file:///home/Piotr/tmp/libxml2/catalog.xml not found in file hash 7077992 Parsing catalog file:///home/Piotr/tmp/libxml2/catalog.xml file:///home/Piotr/tmp/libxml2/catalog.xml added to file hash Found system match header.xml, using file:///home/Piotr/tmp/libxml2/level1/header.xml <?xml version="1.0" encoding="UTF-8"?> <?oasis-xml-catalog catalog="./catalog.xml"?> <text xmlns:xi="http://www.w3.org/2001/XInclude"> <header xml:base="file:///home/Piotr/tmp/libxml2/level1/header.xml"> <info>this is the header</info> </header> <p>some stuff here</p> </text> Catalogs cleanup Free catalog entry /home/Piotr/tmp/libxml2/catalog.xml <---------- note this Free catalog entry file:///etc/xml/catalog Free catalog entry header.xml Free catalog entry file:///home/Piotr/tmp/libxml2/catalog.xml Free catalog entry --- $ xmllint --version xmllint: using libxml version 20706 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib (running in newly updated Cygwin) --- Note also bug #167289 (except that there the catalog loads too late), but FWIW let me note that my report is also true of cases when I use --relaxng validation.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.