[Python-checkins] r46773 - in python/trunk/Lib: test/test_sax.py xmlcore/sax/saxutils.py
andrew.kuchling
python-checkins at python.org
Fri Jun 9 15:15:57 CEST 2006
Author: andrew.kuchling
Date: Fri Jun 9 15:15:57 2006
New Revision: 46773
Modified:
python/trunk/Lib/test/test_sax.py
python/trunk/Lib/xmlcore/sax/saxutils.py
Log:
[Bug #1472827] Make saxutils.XMLGenerator handle \r\n\t in attribute values by escaping them properly. 2.4 bugfix candidate.
Modified: python/trunk/Lib/test/test_sax.py
==============================================================================
--- python/trunk/Lib/test/test_sax.py (original)
+++ python/trunk/Lib/test/test_sax.py Fri Jun 9 15:15:57 2006
@@ -175,11 +175,14 @@
gen.endElement("e")
gen.startElement("e", {"a": "'\""})
gen.endElement("e")
+ gen.startElement("e", {"a": "\n\r\t"})
+ gen.endElement("e")
gen.endElement("doc")
gen.endDocument()
- return result.getvalue() == start \
- + "<doc a='\"'><e a=\"'\"></e><e a=\"'"\"></e></doc>"
+ return result.getvalue() == start + ("<doc a='\"'><e a=\"'\"></e>"
+ "<e a=\"'"\"></e>"
+ "<e a=\" 	\"></e></doc>")
def test_xmlgen_ignorable():
result = StringIO()
Modified: python/trunk/Lib/xmlcore/sax/saxutils.py
==============================================================================
--- python/trunk/Lib/xmlcore/sax/saxutils.py (original)
+++ python/trunk/Lib/xmlcore/sax/saxutils.py Fri Jun 9 15:15:57 2006
@@ -68,6 +68,8 @@
the optional entities parameter. The keys and values must all be
strings; each key will be replaced with its corresponding value.
"""
+ entities = entities.copy()
+ entities.update({'\n': ' ', '\r': ' ', '\t':'	'})
data = escape(data, entities)
if '"' in data:
if "'" in data:
More information about the Python-checkins
mailing list