1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

parser: Fix namespaces redefined from default attributes

This regressed in commit e0dd330b.

Also fixes a long-standing issue where namespaces from default
attributes weren't added if they match an existing namespace.

Fixes #643.
This commit is contained in:
Nick Wellnhofer
2023-12-08 12:13:49 +01:00
parent df0b540b3e
commit 7d446e9736
10 changed files with 91 additions and 9 deletions

View File

@@ -1689,13 +1689,11 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
oldIndex = ctxt->nsdb->defaultNsIndex;
if (oldIndex != INT_MAX) {
if (defAttr != 0)
return(0);
extra = &ctxt->nsdb->extra[oldIndex];
if (extra->elementId == ctxt->nsdb->elementId) {
xmlErrAttributeDup(ctxt, NULL, BAD_CAST "xmlns");
if (defAttr == 0)
xmlErrAttributeDup(ctxt, NULL, BAD_CAST "xmlns");
return(0);
}
@@ -1715,14 +1713,12 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
if (oldIndex != INT_MAX) {
extra = &ctxt->nsdb->extra[oldIndex];
if (defAttr != 0)
return(0);
/*
* Check for duplicate definitions on the same element.
*/
if (extra->elementId == ctxt->nsdb->elementId) {
xmlErrAttributeDup(ctxt, BAD_CAST "xmlns", prefix->name);
if (defAttr == 0)
xmlErrAttributeDup(ctxt, BAD_CAST "xmlns", prefix->name);
return(0);
}