add a new function xmlPathToUri() to provide a clean conversion when
* uri.c include/libxml/uri.h: add a new function xmlPathToUri()
to provide a clean conversion when setting up a base
* SAX2.c tree.c: use said function when setting up doc->URL
or using the xmlSetBase function. Should fix #346261
Daniel
diff --git a/tree.c b/tree.c
index 07a555a..805c8c7 100644
--- a/tree.c
+++ b/tree.c
@@ -4800,6 +4800,7 @@
void
xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
xmlNsPtr ns;
+ const xmlChar* fixed;
if (cur == NULL) return;
switch(cur->type) {
@@ -4835,7 +4836,7 @@
if (uri == NULL)
doc->URL = NULL;
else
- doc->URL = xmlStrdup(uri);
+ doc->URL = xmlPathToURI(uri);
return;
}
}
@@ -4843,7 +4844,13 @@
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
if (ns == NULL)
return;
- xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
+ fixed = xmlPathToURI(uri);
+ if (fixed != NULL) {
+ xmlSetNsProp(cur, ns, BAD_CAST "base", fixed);
+ xmlFree(fixed);
+ } else {
+ xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
+ }
}
#endif /* LIBXML_TREE_ENABLED */