[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user