This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: xml.sax.xmlreader.AttributesImpl allows empty string as attribute names
Type: behavior Stage:
Components: XML Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Chenguang.Wang, Michael.Sulyaev, Ramchandra Apte, iritkatriel
Priority: normal Keywords: patch

Created on 2011-09-02 10:04 by Michael.Sulyaev, last changed 2022-04-11 14:57 by admin.

File name Uploaded Description Edit
w.patch Chenguang.Wang, 2013-01-31 07:44 review
Messages (4)
msg143391 - (view) Author: Michael Sulyaev (Michael.Sulyaev) Date: 2011-09-02 10:04
I can get not-well-formed XML output (attribute name must not be empty string):

<?xml version="1.0" encoding="iso-8859-1"?>
<root ="v_for_empty_name" k1="v1"></root>

AttributeImpl must ignore dict entries that may not be cast to valid XML attributes.



from xml.sax.xmlreader import AttributesImpl as Attrs
from xml.sax.saxutils import XMLGenerator as Gen

g = Gen()
a = Attrs(dict([('k1','v1'),('','v_for_empty_name')]))
msg180964 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-30 05:31
msg181008 - (view) Author: Chenguang Wang (Chenguang.Wang) Date: 2013-01-31 07:44
I found this problem is still not fixed in the lastest hg version. Seriously?

This patch is for the latest v3.4.0a0.
msg392406 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-04-30 10:10
I don't think the proposed patch is an acceptable solution. It silently skips invalid attributes.  

It would be ok to either raise an exception or to leave it as it is (junk-in-junk-out).  I'm not sure which is better.
Date User Action Args
2022-04-11 14:57:21adminsetgithub: 57092
2021-04-30 10:10:21iritkatrielsetnosy: + iritkatriel

messages: + msg392406
versions: + Python 3.11, - Python 2.6
2013-01-31 07:44:27Chenguang.Wangsetfiles: + w.patch

nosy: + Chenguang.Wang
messages: + msg181008

keywords: + patch
2013-01-30 05:31:10Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg180964
2011-09-02 10:04:02Michael.Sulyaevcreate