diff --git a/ietf/secr/proceedings/utils.py b/ietf/secr/proceedings/utils.py index 8e9dc6ef4..39d9a6a05 100644 --- a/ietf/secr/proceedings/utils.py +++ b/ietf/secr/proceedings/utils.py @@ -4,6 +4,7 @@ import os from django.conf import settings from django.contrib import messages +from django.utils.encoding import smart_text import debug # pyflakes:ignore @@ -36,8 +37,9 @@ def handle_upload_file(file,filename,meeting,subdir, request=None): destination = open(os.path.join(path,filename), 'wb+') if extension in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS['text/html']: file.open() - text = file.read().decode('utf-8') - # Whole file sanitization; add back '' (sanitize will remove it) + text = smart_text(file.read()) + # Whole file sanitization; add back what's missing from a complete + # document (sanitize will remove these). clean = u""" %s diff --git a/ietf/utils/html.py b/ietf/utils/html.py index 1715fec69..5fb74bbab 100644 --- a/ietf/utils/html.py +++ b/ietf/utils/html.py @@ -26,7 +26,7 @@ class StripFilter(Filter): for token in Filter.__iter__(self): if token["type"] in ["EmptyTag", "StartTag"]: open_tags.append(token["name"]) - if not set(strip_completely) & set(open_tags): + if not (set(open_tags) & set(strip_completely)): yield token if token["type"] in ["EmptyTag", "EndTag"]: open_tags.pop()