Merge pull request #1625 from Scimonster/master

Fix #1624 -- Unicode in XML sanitizing causes error
This commit is contained in:
mdipierro
2017-06-05 11:39:52 -05:00
committed by GitHub
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -596,10 +596,10 @@ class XML(XmlComponent):
for A, IMG and BlockQuote).
The key is the tag; the value is a list of allowed attributes.
"""
if sanitize:
text = sanitizer.sanitize(text, permitted_tags, allowed_attributes)
if isinstance(text, unicodeT):
text = to_native(text.encode('utf8', 'xmlcharrefreplace'))
if sanitize:
text = sanitizer.sanitize(text, permitted_tags, allowed_attributes)
elif isinstance(text, bytes):
text = to_native(text)
elif not isinstance(text, str):