[FIX] scaffold: correctly decode utf8 templates

As its documentation notes[0], Jinja2 only processes unicode template
data (or pure ASCII, which will implicitly decode to unicode).

The scaffolding system would read raw scaffolding data in memory (both
templates and passthrough non-templates), but fail to decode templates
before handing them to Jinja, blowing rendering up if templates
contained non-ascii.

Fix #11331 by always decoding templates from UTF8 before handing them
to jinja. This is backwards-compatible, ascii templates work as they
used to, non-ascii UTF8 templates now work correctly, non-ascii
non-UTF8 templates what are you doing?

[0] http://jinja.pocoo.org/docs/dev/api/#unicode
This commit is contained in:
xmo-odoo 2016-03-15 11:25:16 +01:00
parent d377ffd5bf
commit c824e50b3f
1 changed files with 1 additions and 1 deletions

View File

@ -126,7 +126,7 @@ class template(object):
if ext not in ('.py', '.xml', '.csv', '.js', '.rst', '.html', '.template'):
f.write(content)
else:
env.from_string(content)\
env.from_string(content.decode('utf-8'))\
.stream(params or {})\
.dump(f, encoding='utf-8')