mirror of https://github.com/python/cpython.git
[Bug #1472827] Make saxutils.XMLGenerator handle \r\n\t in attribute values by escaping them properly. 2.4 bugfix candidate.
This commit is contained in:
parent
7dbb1ff77d
commit
91c64a05d2
|
@ -175,11 +175,14 @@ def test_xmlgen_attr_escape():
|
||||||
gen.endElement("e")
|
gen.endElement("e")
|
||||||
gen.startElement("e", {"a": "'\""})
|
gen.startElement("e", {"a": "'\""})
|
||||||
gen.endElement("e")
|
gen.endElement("e")
|
||||||
|
gen.startElement("e", {"a": "\n\r\t"})
|
||||||
|
gen.endElement("e")
|
||||||
gen.endElement("doc")
|
gen.endElement("doc")
|
||||||
gen.endDocument()
|
gen.endDocument()
|
||||||
|
|
||||||
return result.getvalue() == start \
|
return result.getvalue() == start + ("<doc a='\"'><e a=\"'\"></e>"
|
||||||
+ "<doc a='\"'><e a=\"'\"></e><e a=\"'"\"></e></doc>"
|
"<e a=\"'"\"></e>"
|
||||||
|
"<e a=\" 	\"></e></doc>")
|
||||||
|
|
||||||
def test_xmlgen_ignorable():
|
def test_xmlgen_ignorable():
|
||||||
result = StringIO()
|
result = StringIO()
|
||||||
|
|
|
@ -68,6 +68,8 @@ def quoteattr(data, entities={}):
|
||||||
the optional entities parameter. The keys and values must all be
|
the optional entities parameter. The keys and values must all be
|
||||||
strings; each key will be replaced with its corresponding value.
|
strings; each key will be replaced with its corresponding value.
|
||||||
"""
|
"""
|
||||||
|
entities = entities.copy()
|
||||||
|
entities.update({'\n': ' ', '\r': ' ', '\t':'	'})
|
||||||
data = escape(data, entities)
|
data = escape(data, entities)
|
||||||
if '"' in data:
|
if '"' in data:
|
||||||
if "'" in data:
|
if "'" in data:
|
||||||
|
|
Loading…
Reference in New Issue