mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
7b5aa463f9
commit
42fb6ab491
4 changed files with 25 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue