diff --git a/docxtpl/__init__.py b/docxtpl/__init__.py index 7ee5f81..b91a670 100644 --- a/docxtpl/__init__.py +++ b/docxtpl/__init__.py @@ -181,7 +181,7 @@ class DocxTemplate(object): """Escape string values of the passed :dict: `d` in-place including nested dictionaries of any depth. """ - for k, v in d.items(): + for k, v in six.iteritems(d): if isinstance(v, dict): identity = id(v) if identity not in identities: diff --git a/tests/escape_auto.py b/tests/escape_auto.py index d792fc2..ffa2b0a 100644 --- a/tests/escape_auto.py +++ b/tests/escape_auto.py @@ -3,10 +3,10 @@ from docxtpl import * tpl = DocxTemplate("test_files/escape_tpl_auto.docx") context = {'myvar': R('"less than" must be escaped : <, this can be done with RichText() or R()'), - 'myescvar':'It can be escaped with a "|e" jinja filter in the template too : < ', - 'nlnp' : R('Here is a multiple\nlines\nstring\aand some\aother\aparagraphs\aNOTE: the current character styling is removed'), + 'myescvar': 'It can be escaped with a "|e" jinja filter in the template too : < ', + 'nlnp': R('Here is a multiple\nlines\nstring\aand some\aother\aparagraphs\aNOTE: the current character styling is removed'), 'mylisting': Listing('the listing\nwith\nsome\nlines\nand special chars : <>&'), - 'autoescape': """These string should be auto escaped for an XML Word document which may contain <, >, &, ", and '.""" + 'autoescape': """<, >, &, ", and '.""" } tpl.render(context, autoescape=True) diff --git a/tests/test_files/escape_auto.docx b/tests/test_files/escape_auto.docx index fc0e54c..c4ed5f0 100644 Binary files a/tests/test_files/escape_auto.docx and b/tests/test_files/escape_auto.docx differ diff --git a/tests/test_files/escape_tpl_auto.docx b/tests/test_files/escape_tpl_auto.docx index c6f7a6c..4d59e55 100644 Binary files a/tests/test_files/escape_tpl_auto.docx and b/tests/test_files/escape_tpl_auto.docx differ