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 520674 - xmlNewTextWriterFilename incorrectly rejects some uris
xmlNewTextWriterFilename incorrectly rejects some uris
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xmlwriter
2.6.30
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-06 05:43 UTC by Steven Thomas
Modified: 2021-07-05 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Steven Thomas 2008-03-06 05:43:26 UTC
Please describe the problem:
The xmlNewTextWriterFilename function rejects some uris that have a scheme but no authority, such as file:/home/sthomas/file.xml. If you insert an empty authority component, as in file:///home/sthomas/file.xml, it works. The xmlReaderForFile function has no problem with authority-less uris.

Steps to reproduce:
// Here's a program that demonstrates the problem

#include <string>
#include <iostream>
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>

using namespace std;

void attemptReadFile(string uri) {
	xmlTextReaderPtr reader = xmlReaderForFile(uri.c_str(), NULL, 0);
	cout << "read " << uri << " " << (reader ? "succeeded" : "failed") << endl;
	xmlFreeTextReader(reader);
}

void attemptWriteFile(string uri) {
	xmlTextWriterPtr writer = xmlNewTextWriterFilename(uri.c_str(), 0);
	cout << "write " << uri << " " << (writer ? "succeeded" : "failed") << endl;
	xmlFreeTextWriter(writer);
}

int main() {
	// Creating an xmlTextWriter without an authority component in the uri
	// fails. It works for xmlTextReaders...
	attemptReadFile("/home/sthomas/file.xml");        // Works
	attemptReadFile("file:/home/sthomas/file.xml");   // Works
	attemptReadFile("file:///home/sthomas/file.xml"); // Works

	// ... but not xmlTextWriters
	attemptWriteFile("/home/sthomas/file2.xml");        // Works
	attemptWriteFile("file:/home/sthomas/file2.xml");   // Fails!
	attemptWriteFile("file:///home/sthomas/file2.xml"); // Works

	return 0;
}


Actual results:
Writing to the uri "file:/home/sthomas/file2.xml" fails.

Expected results:
Writing to that uri should work fine.

Does this happen every time?
Yes

Other information:
Comment 1 GNOME Infrastructure Team 2021-07-05 13:22:44 UTC
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.