1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-11 05:17:37 +03:00

parser: Fix detection of duplicate attributes in XML namespace

Fixes a regression from commit e0dd330b, resulting in duplicate
attributes in the predefined XML namespace not being detected or
extraneous default attributes being passed.

Fixes #704.
This commit is contained in:
Nick Wellnhofer 2024-03-12 19:55:33 +01:00
parent ce8f3d2c1d
commit 186562a182
13 changed files with 98 additions and 1 deletions

View File

@ -8910,7 +8910,7 @@ xmlAttrHashInsert(xmlParserCtxtPtr ctxt, unsigned size, const xmlChar *name,
int nsIndex = (int) (ptrdiff_t) atts[2];
if ((nsIndex == NS_INDEX_EMPTY) ? (uri == NULL) :
(nsIndex == NS_INDEX_XML) ? (uri == ctxt->str_xml) :
(nsIndex == NS_INDEX_XML) ? (uri == ctxt->str_xml_ns) :
(uri == ctxt->nsTab[nsIndex * 2 + 1]))
return(bucket->index);
}

7
result/def-xml-attr.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ATTLIST foo xml:lang CDATA "eng">
]>
<root>
<foo xml:lang="ger">Ja</foo>
</root>

View File

@ -0,0 +1,10 @@
0 10 root 0 0
0 1 root 0 0
1 14 #text 0 1
1 1 foo 0 0
2 3 #text 0 1 Ja
1 15 foo 0 0
1 14 #text 0 1
0 15 root 0 0

View File

@ -0,0 +1,10 @@
0 10 root 0 0
0 1 root 0 0
1 14 #text 0 1
1 1 foo 0 0
2 3 #text 0 1 Ja
1 15 foo 0 0
1 14 #text 0 1
0 15 root 0 0

View File

@ -0,0 +1,15 @@
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(root, , )
SAX.attributeDecl(foo, xml:lang, 1, 1, eng, ...)
SAX.externalSubset(root, , )
SAX.startElement(root)
SAX.characters(
, 3)
SAX.startElement(foo, xml:lang='ger')
SAX.characters(Ja, 2)
SAX.endElement(foo)
SAX.characters(
, 1)
SAX.endElement(root)
SAX.endDocument()

View File

@ -0,0 +1,15 @@
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(root, , )
SAX.attributeDecl(foo, xml:lang, 1, 1, eng, ...)
SAX.externalSubset(root, , )
SAX.startElementNs(root, NULL, NULL, 0, 0, 0)
SAX.characters(
, 3)
SAX.startElementNs(foo, NULL, NULL, 0, 1, 0, xml:lang='ger"...', 3)
SAX.characters(Ja, 2)
SAX.endElementNs(foo, NULL, NULL)
SAX.characters(
, 1)
SAX.endElementNs(root, NULL, NULL)
SAX.endDocument()

View File

@ -0,0 +1,3 @@
./test/errors/dup-xml-attr.xml:1: parser error : Attribute xml:lang redefined
<doc xml:lang="en" xml:lang="de"/>
^

View File

@ -0,0 +1,3 @@
./test/errors/dup-xml-attr.xml:1: parser error : Attribute xml:lang redefined
<doc xml:lang="en" xml:lang="de"/>
^

View File

@ -0,0 +1,4 @@
./test/errors/dup-xml-attr.xml:1: parser error : Attribute xml:lang redefined
<doc xml:lang="en" xml:lang="de"/>
^
./test/errors/dup-xml-attr.xml : failed to parse

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ATTLIST foo xml:lang CDATA "eng">
]>
<root>
<foo xml:lang="ger">Ja</foo>
</root>

View File

@ -0,0 +1,15 @@
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(root, , )
SAX.attributeDecl(foo, xml:lang, 1, 1, eng, ...)
SAX.externalSubset(root, , )
SAX.startElementNs(root, NULL, NULL, 0, 0, 0)
SAX.characters(
, 3)
SAX.startElementNs(foo, NULL, NULL, 0, 1, 0, xml:lang='ger"...', 3)
SAX.characters(Ja, 2)
SAX.endElementNs(foo, NULL, NULL)
SAX.characters(
, 1)
SAX.endElementNs(root, NULL, NULL)
SAX.endDocument()

7
test/def-xml-attr.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ATTLIST foo xml:lang CDATA "eng">
]>
<root>
<foo xml:lang="ger">Ja</foo>
</root>

View File

@ -0,0 +1 @@
<doc xml:lang="en" xml:lang="de"/>