def wrap_field(field):
"""
Given a field, detect if it has special characters <, > or & and if so
wrap it in a CDATA field.
"""
if not isinstance(field, str):
return field
if html_chars.search(field):
return '<![CDATA[' + field + ']]>'
else:
# If there's already escaped data like &, I want to unescape it
# first, so I can re-escape *everything*
field = saxutils.unescape(field)
return saxutils.escape(field)
评论列表
文章目录