mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00: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:
parent
df0b540b3e
commit
7d446e9736
8
parser.c
8
parser.c
@ -1689,12 +1689,10 @@ 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) {
|
||||
if (defAttr == 0)
|
||||
xmlErrAttributeDup(ctxt, NULL, BAD_CAST "xmlns");
|
||||
return(0);
|
||||
}
|
||||
@ -1715,13 +1713,11 @@ 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) {
|
||||
if (defAttr == 0)
|
||||
xmlErrAttributeDup(ctxt, BAD_CAST "xmlns", prefix->name);
|
||||
return(0);
|
||||
}
|
||||
|
8
result/issue643.xml
Normal file
8
result/issue643.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST elem xmlns CDATA #FIXED "urn:def2">
|
||||
<!ATTLIST elem xmlns:a CDATA #FIXED "urn:a2">
|
||||
]>
|
||||
<doc xmlns="urn:def" xmlns:a="urn:a">
|
||||
<elem xmlns="urn:def2" xmlns:a="urn:a2"/>
|
||||
</doc>
|
8
result/issue643.xml.rde
Normal file
8
result/issue643.xml.rde
Normal file
@ -0,0 +1,8 @@
|
||||
0 10 doc 0 0
|
||||
0 1 doc 0 0
|
||||
1 14 #text 0 1
|
||||
|
||||
1 1 elem 1 0
|
||||
1 14 #text 0 1
|
||||
|
||||
0 15 doc 0 0
|
8
result/issue643.xml.rdr
Normal file
8
result/issue643.xml.rdr
Normal file
@ -0,0 +1,8 @@
|
||||
0 10 doc 0 0
|
||||
0 1 doc 0 0
|
||||
1 14 #text 0 1
|
||||
|
||||
1 1 elem 1 0
|
||||
1 14 #text 0 1
|
||||
|
||||
0 15 doc 0 0
|
15
result/issue643.xml.sax
Normal file
15
result/issue643.xml.sax
Normal file
@ -0,0 +1,15 @@
|
||||
SAX.setDocumentLocator()
|
||||
SAX.startDocument()
|
||||
SAX.internalSubset(doc, , )
|
||||
SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
|
||||
SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
|
||||
SAX.externalSubset(doc, , )
|
||||
SAX.startElement(doc, xmlns='urn:def', xmlns:a='urn:a')
|
||||
SAX.characters(
|
||||
, 5)
|
||||
SAX.startElement(elem)
|
||||
SAX.endElement(elem)
|
||||
SAX.characters(
|
||||
, 1)
|
||||
SAX.endElement(doc)
|
||||
SAX.endDocument()
|
15
result/issue643.xml.sax2
Normal file
15
result/issue643.xml.sax2
Normal file
@ -0,0 +1,15 @@
|
||||
SAX.setDocumentLocator()
|
||||
SAX.startDocument()
|
||||
SAX.internalSubset(doc, , )
|
||||
SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
|
||||
SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
|
||||
SAX.externalSubset(doc, , )
|
||||
SAX.startElementNs(doc, NULL, 'urn:def', 2, xmlns='urn:def', xmlns:a='urn:a', 0, 0)
|
||||
SAX.characters(
|
||||
, 5)
|
||||
SAX.startElementNs(elem, NULL, 'urn:def2', 2, xmlns='urn:def2', xmlns:a='urn:a2', 0, 0)
|
||||
SAX.endElementNs(elem, NULL, 'urn:def2')
|
||||
SAX.characters(
|
||||
, 1)
|
||||
SAX.endElementNs(doc, NULL, 'urn:def')
|
||||
SAX.endDocument()
|
8
result/noent/issue643.xml
Normal file
8
result/noent/issue643.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST elem xmlns CDATA #FIXED "urn:def2">
|
||||
<!ATTLIST elem xmlns:a CDATA #FIXED "urn:a2">
|
||||
]>
|
||||
<doc xmlns="urn:def" xmlns:a="urn:a">
|
||||
<elem xmlns="urn:def2" xmlns:a="urn:a2"/>
|
||||
</doc>
|
15
result/noent/issue643.xml.sax2
Normal file
15
result/noent/issue643.xml.sax2
Normal file
@ -0,0 +1,15 @@
|
||||
SAX.setDocumentLocator()
|
||||
SAX.startDocument()
|
||||
SAX.internalSubset(doc, , )
|
||||
SAX.attributeDecl(elem, xmlns, 1, 4, urn:def2, ...)
|
||||
SAX.attributeDecl(elem, xmlns:a, 1, 4, urn:a2, ...)
|
||||
SAX.externalSubset(doc, , )
|
||||
SAX.startElementNs(doc, NULL, 'urn:def', 2, xmlns='urn:def', xmlns:a='urn:a', 0, 0)
|
||||
SAX.characters(
|
||||
, 5)
|
||||
SAX.startElementNs(elem, NULL, 'urn:def2', 2, xmlns='urn:def2', xmlns:a='urn:a2', 0, 0)
|
||||
SAX.endElementNs(elem, NULL, 'urn:def2')
|
||||
SAX.characters(
|
||||
, 1)
|
||||
SAX.endElementNs(doc, NULL, 'urn:def')
|
||||
SAX.endDocument()
|
@ -7,5 +7,5 @@
|
||||
<!ATTLIST a:inner attr CDATA #FIXED "yes">
|
||||
]>
|
||||
<a:outer xmlns:a="urn:namespace">
|
||||
<a:inner/>
|
||||
<a:inner xmlns:a="urn:namespace"/>
|
||||
</a:outer>
|
||||
|
9
test/issue643.xml
Normal file
9
test/issue643.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ATTLIST elem xmlns CDATA #FIXED 'urn:def2'>
|
||||
<!ATTLIST elem xmlns:a CDATA #FIXED 'urn:a2'>
|
||||
]>
|
||||
|
||||
<doc xmlns="urn:def" xmlns:a="urn:a">
|
||||
<elem/>
|
||||
</doc>
|
Loading…
x
Reference in New Issue
Block a user