GNOME Bugzilla – Bug 731063
xmlSaveUri() incorrectly recomposes URIs with rootless paths
Last modified: 2016-01-21 04:28:52 UTC
Created attachment 277654 [details] [review] Patch to fix recomposing URIs with rootless paths in xmlSaveUri() xmlSaveUri() of libxml2 (snapshot 2014-05-31 and earlier) returns bogus values when called with URIs that have rootless paths (e.g. "urx:b:b" becomes "urx://b%3Ab" where "urx:b%3Ab" would be correct). This program demonstrates it: /* gcc -lxml2 -o xmlSaveUri xmlSaveUri.c */ #include <stdio.h> #include <libxml2/libxml/uri.h> int main (void) { return printf("Returns `%s'.\n", xmlSaveUri(xmlParseURI("urx:b:b"))); } This behaviour makes it impossible to process Open/LibreOffice files with XInclude because of their namespace URIs (e.g. "urn:oasis:names:tc:opendocument:xmlns:office:1.0"). It also violates section 3 of RFC3986 which states that a URI can only have "//" immediately after the scheme part IF it contains an authority part which is not the case here. Section 5.3 mentions it, too. The attached patch should fix the error.
So that patch was actually pushed into git back in June, this raised a couple of issues and led to subsequent patches, but this should be all solved now. BTW the libxml2 code has a testURI.c utility already: thinkpad:~/XML -> ./testURI urx:b:b urx:b%3Ab thinkpad:~/XML -> ./testURI urx:/ urx:/ thinkpad:~/XML -> ./testURI urx:// urx:// thinkpad:~/XML -> ./testURI urx:/// urx:/// thinkpad:~/XML -> ./testURI urx:///foo urx:///foo thinkpad:~/XML -> ./testURI urx://foo urx://foo thinkpad:~/XML -> ./testURI urx:/foo urx:/foo thinkpad:~/XML -> ./testURI urx:foo urx:foo thinkpad:~/XML -> thanks ! Daniel
This fix may have caused: Bug 760921: REGRESSION (8eb55d78): doc/examples/io1 test fails after fix for "xmlSaveUri() incorrectly recomposes URIs with rootless paths" <https://bugzilla.gnome.org/show_bug.cgi?id=760921>