From d1b0d2586b82a883f21914c64b76aaffe3a42550 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 4 Jun 2014 00:08:01 +0200 Subject: [PATCH] [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. --- openerp/addons/base/ir/ir_qweb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 11c2432a874..6e434c2ab1d 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -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