mirror of
https://github.com/python/cpython.git
synced 2025-11-13 07:26:31 +00:00
Escape special characters on output.
This commit is contained in:
parent
348fd06890
commit
79ad1f19dc
1 changed files with 4 additions and 2 deletions
|
|
@ -12,13 +12,15 @@ import esistools
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
from xml.utils import escape
|
||||||
|
|
||||||
|
|
||||||
def format_attrs(attrs):
|
def format_attrs(attrs):
|
||||||
attrs = attrs.items()
|
attrs = attrs.items()
|
||||||
attrs.sort()
|
attrs.sort()
|
||||||
s = ''
|
s = ''
|
||||||
for name, value in attrs:
|
for name, value in attrs:
|
||||||
s = '%s %s="%s"' % (s, name, value)
|
s = '%s %s="%s"' % (s, name, escape(value))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -39,7 +41,7 @@ def do_convert(ifp, ofp, xml=0):
|
||||||
data = data[:-1]
|
data = data[:-1]
|
||||||
if type == "-":
|
if type == "-":
|
||||||
data = esistools.decode(data)
|
data = esistools.decode(data)
|
||||||
ofp.write(data)
|
ofp.write(escape(data))
|
||||||
if "\n" in data:
|
if "\n" in data:
|
||||||
lastopened = None
|
lastopened = None
|
||||||
knownempty = 0
|
knownempty = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue