Commit 0a6a60d0 authored by fred's avatar fred
Browse files

extend xml illegal characters fix to all illegal characters

parent 81bab034
......@@ -373,4 +373,11 @@ def as_absolute_url(url):
@register.filter
def xml_illegal_fix(text):
# django.utils.xmlutils.UnserializableContentError: Control characters are not supported in XML 1.0
return text.replace('\x02', ' ')
for i in range(0x20): # remove control characters
char = chr(i)
if char in ('\t', '\r', '\n'):
# only allow tab, carriage return and line feed.
continue
text = text.replace(char, '')
# fffe and ffff are also invalid characters
return text.replace('\ufffe', '').replace('\uffff', '')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment