summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-02-09 17:08:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-02-09 17:08:05 (GMT)
commit42fb6ab49128f14cd353ec86a177ddda6763812e (patch)
treea2a56b68bc65883013bd8cc14cb40a53a1e9d6c6 /Lib/xml
parent7b5aa463f99f600803207ea4bc1aa63b4befdd7d (diff)
downloadcpython-42fb6ab49128f14cd353ec86a177ddda6763812e.zip
cpython-42fb6ab49128f14cd353ec86a177ddda6763812e.tar.gz
cpython-42fb6ab49128f14cd353ec86a177ddda6763812e.tar.bz2
Issue #2746: Don't escape ampersands and angle brackets ("&", "<", ">")
in XML processing instructions and comments. These raw characters are allowed by the XML specification, and are necessary when outputting e.g. PHP code in a processing instruction. Patch by Neil Muller.
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/etree/ElementTree.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index 7dbc72e..e5afcbc 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -666,9 +666,9 @@ class ElementTree:
# write XML to file
tag = node.tag
if tag is Comment:
- file.write("<!-- %s -->" % _escape_cdata(node.text, encoding))
+ file.write("<!-- %s -->" % _encode(node.text, encoding))
elif tag is ProcessingInstruction:
- file.write("<?%s?>" % _escape_cdata(node.text, encoding))
+ file.write("<?%s?>" % _encode(node.text, encoding))
else:
items = node.items()
xmlns_items = [] # new namespaces in this scope