mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
Fix handling of XML-1.0 XML namespace declaration
Usually 'xml' namespace for XML-1.0 declaration does not need to be carried but Mike Hommey raised the problem that the SVG XSD file fails to parse due to a mishandling. - SAX2.c: failure to create a namespace should not be interpreted as a memory allocation error - tree.c: document better xmlNewNs behaviour, and fix it in the case the 'xml' prefix is being used.
This commit is contained in:
8
SAX2.c
8
SAX2.c
@@ -2242,8 +2242,12 @@ xmlSAX2StartElementNs(void *ctx,
|
|||||||
if ((URI != NULL) && (prefix == pref))
|
if ((URI != NULL) && (prefix == pref))
|
||||||
ret->ns = ns;
|
ret->ns = ns;
|
||||||
} else {
|
} else {
|
||||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
/*
|
||||||
return;
|
* any out of memory error would already have been raised
|
||||||
|
* but we can't be garanteed it's the actual error due to the
|
||||||
|
* API, best is to skip in this case
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef LIBXML_VALID_ENABLED
|
#ifdef LIBXML_VALID_ENABLED
|
||||||
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
|
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
|
||||||
|
|||||||
13
tree.c
13
tree.c
@@ -721,9 +721,20 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
|
|||||||
if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
|
if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml")))
|
if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
|
||||||
|
/* xml namespace is predefined, no need to add it */
|
||||||
|
if (xmlStrEqual(href, XML_XML_NAMESPACE))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Problem, this is an attempt to bind xml prefix to a wrong
|
||||||
|
* namespace, which breaks
|
||||||
|
* Namespace constraint: Reserved Prefixes and Namespace Names
|
||||||
|
* from XML namespace. But documents authors may not care in
|
||||||
|
* their context so let's proceed.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a new Namespace and fill the fields.
|
* Allocate a new Namespace and fill the fields.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user