[FIX] ir_qweb: decoding of attachment assets
For uploaded modules (e.g. saas), uploaded assets are stored in attachments. When the asset content is retrieved, static "filesystem" files are assumed to be UTF8 and properly decoded, but attachment data is not and is thus interpreted as ASCII further down the line, leading to a UnicodeDecodeError (and a broken page/template/...) if the asset data is not actually ASCII (e.g. if it's UTF-8). Fix by treating attachment assets as UTF8 encoded, same as filesystem assets. OPW-752858
This commit is contained in:
@@ -479,7 +479,7 @@ class WebAsset(object):
|
||||
with open(self._filename, 'rb') as fp:
|
||||
return fp.read().decode('utf-8')
|
||||
else:
|
||||
return self._ir_attach['datas'].decode('base64')
|
||||
return self._ir_attach['datas'].decode('base64').decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
raise AssetError('%s is not utf-8 encoded.' % self.name)
|
||||
except IOError:
|
||||
|
||||
Reference in New Issue
Block a user