From 1e3d6f6db30b8b74531fef5d5096b9783eeb318c Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Thu, 26 Sep 2019 16:34:35 -0400 Subject: [PATCH] Fix parsing of Unicode capa XML BOM-611 (#21803) --- common/lib/capa/capa/capa_problem.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index d00ce0ceaa..7ab2b180a2 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -185,6 +185,9 @@ class LoncapaProblem(object): self.problem_text = problem_text # parse problem XML file into an element tree + if isinstance(problem_text, six.text_type): + # etree chokes on Unicode XML with an encoding declaration + problem_text = problem_text.encode('utf-8') self.tree = etree.XML(problem_text) self.make_xml_compatible(self.tree)