From 64a85e19e7cc93c1244c93381748c2019b764e44 Mon Sep 17 00:00:00 2001 From: Nate Hardison Date: Mon, 3 Jun 2013 17:19:33 -0700 Subject: [PATCH] Specify UTF-8 encoding when loading Mako template When loading a Mako template from a Django template, the file encoding of the Mako template was left unspecified. In some cases, this would cause the Mako template to be interpreted as an ASCII template, resulting in blowups if the template was encoded in UTF-8 (e.g., lms/templates/footer.html). Now, both the input and output encodings are specified as UTF-8. --- common/djangoapps/mitxmako/makoloader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/djangoapps/mitxmako/makoloader.py b/common/djangoapps/mitxmako/makoloader.py index d623e8bcff..6b6b31d464 100644 --- a/common/djangoapps/mitxmako/makoloader.py +++ b/common/djangoapps/mitxmako/makoloader.py @@ -44,7 +44,11 @@ class MakoLoader(object): if source.startswith("## mako\n"): # This is a mako template - template = Template(filename=file_path, module_directory=self.module_directory, uri=template_name) + template = Template(filename=file_path, + module_directory=self.module_directory, + input_encoding='utf-8', + output_encoding='utf-8', + uri=template_name) return template, None else: # This is a regular template