[FIX] ir.qweb: rendering non-string attributes could cause unicode errors (Issue #282)

This occurs because werkzeug.utils.escape() auto-casts
non-basestring values to unicode, while we expect to be
working with bytestrings only.
So when evaluating attribute values, make sure we always
return bytestring values, never int, bool or unicode.
This commit is contained in:
Olivier Dony
2014-06-05 10:11:23 +02:00
parent 651e5acd5d
commit d1b0d2586b
+2 -2
View File
@@ -334,10 +334,10 @@ class QWeb(orm.AbstractModel):
att, val = attribute_name[7:], self.eval_format(attribute_value, qwebcontext)
elif attribute_name.startswith("t-att-"):
att, val = attribute_name[6:], self.eval(attribute_value, qwebcontext)
if isinstance(val, unicode):
val = val.encode("utf8")
else:
att, val = self.eval_object(attribute_value, qwebcontext)
if val and not isinstance(val, str):
val = unicode(val).encode("utf8")
return att, val
# Tags