Skip to content

Commit 2fd344f

Browse files
committed
Tweaks to handle text types better and make set operation clearer.
- Legacy-Id: 14745
1 parent 802f201 commit 2fd344f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

ietf/secr/proceedings/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.conf import settings
66
from django.contrib import messages
7+
from django.utils.encoding import smart_text
78

89
import debug # pyflakes:ignore
910

@@ -36,8 +37,9 @@ def handle_upload_file(file,filename,meeting,subdir, request=None):
3637
destination = open(os.path.join(path,filename), 'wb+')
3738
if extension in settings.MEETING_VALID_MIME_TYPE_EXTENSIONS['text/html']:
3839
file.open()
39-
text = file.read().decode('utf-8')
40-
# Whole file sanitization; add back '<html>' (sanitize will remove it)
40+
text = smart_text(file.read())
41+
# Whole file sanitization; add back what's missing from a complete
42+
# document (sanitize will remove these).
4143
clean = u"""<!DOCTYPE html>
4244
<html lang="en">
4345
<head><title>%s</title></head>

ietf/utils/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __iter__(self):
2626
for token in Filter.__iter__(self):
2727
if token["type"] in ["EmptyTag", "StartTag"]:
2828
open_tags.append(token["name"])
29-
if not set(strip_completely) & set(open_tags):
29+
if not (set(open_tags) & set(strip_completely)):
3030
yield token
3131
if token["type"] in ["EmptyTag", "EndTag"]:
3232
open_tags.pop()

0 commit comments

Comments
 (0)