Skip to content

Commit 6a0f8c5

Browse files
committed
Make sure nothing but Unicode goes into the markup cache
1 parent 5d9719c commit 6a0f8c5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎course/content.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def markup_to_html(course, repo, commit_sha, text, reverse_func=None,
757757
cache_key = None
758758
else:
759759
import hashlib
760-
cache_key = ("markup:v5:%s:%d:%s:%s"
760+
cache_key = ("markup:v6:%s:%d:%s:%s"
761761
% (CACHE_KEY_ROOT, course.id, str(commit_sha),
762762
hashlib.md5(text.encode("utf-8")).hexdigest()))
763763

@@ -772,6 +772,9 @@ def markup_to_html(course, repo, commit_sha, text, reverse_func=None,
772772
else:
773773
cache_key = None
774774

775+
if not isinstance(text, six.text_type):
776+
text = six.text_type(text)
777+
775778
# {{{ process through Jinja
776779

777780
from jinja2 import Environment, StrictUndefined
@@ -797,6 +800,7 @@ def markup_to_html(course, repo, commit_sha, text, reverse_func=None,
797800
],
798801
output_format="html5")
799802

803+
assert isinstance(result, six.text_type)
800804
if cache_key is not None:
801805
def_cache.add(cache_key, result, None)
802806

0 commit comments

Comments
 (0)