diff options
| author | Jeremy Kersten <jke@odoo.com> | 2021-01-12 14:40:06 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2021-02-25 15:17:58 +0000 |
| commit | 38983d123d171ac3cc1efacd99d9776f0ed08734 (patch) | |
| tree | 81d01e16e6a8b4b88656d121686ed073d5a5faf9 /addons | |
| parent | 1b729171c5deac4fadebcff013aa061a96860b09 (diff) | |
[FIX] base, web_editor, website: add missing encoding on etree.tostring
Since lxml 4.5.0 that use now use libxml2 2.9.10, without it, it can crash.
Here sample of content that is broken:
https://drive.google.com/file/d/1gB2-jl4fabHscLjH9OZc4WZgtSEbCVj7/view?usp=sharing
note: this commit is to merge 3 changes of #64526
opw-2428617
opw-2428664
closes odoo/odoo#66866
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web_editor/models/ir_ui_view.py | 2 | ||||
| -rw-r--r-- | addons/website/models/website_snippet_filter.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/addons/web_editor/models/ir_ui_view.py b/addons/web_editor/models/ir_ui_view.py index e7fe4b3617d..884e1b5a2f8 100644 --- a/addons/web_editor/models/ir_ui_view.py +++ b/addons/web_editor/models/ir_ui_view.py @@ -343,7 +343,7 @@ class IrUiView(models.Model): full_snippet_key = '%s.%s' % (app_name, snippet_key) # html to xml to add '/' at the end of self closing tags like br, ... - xml_arch = etree.tostring(html.fromstring(arch)) + xml_arch = etree.tostring(html.fromstring(arch), encoding='utf-8') new_snippet_view_values = { 'name': name, 'key': full_snippet_key, diff --git a/addons/website/models/website_snippet_filter.py b/addons/website/models/website_snippet_filter.py index 842cdfec372..cd7ed8eb961 100644 --- a/addons/website/models/website_snippet_filter.py +++ b/addons/website/models/website_snippet_filter.py @@ -60,7 +60,7 @@ class WebsiteSnippetFilter(models.Model): records = self._prepare_values(limit, search_domain) View = self.env['ir.ui.view'].sudo().with_context(inherit_branding=False) content = View._render_template(template_key, dict(records=records)).decode('utf-8') - return [ET.tostring(el) for el in ET.fromstring('<root>%s</root>' % content).getchildren()] + return [ET.tostring(el, encoding='utf-8') for el in ET.fromstring('<root>%s</root>' % content).getchildren()] def _prepare_values(self, limit=None, search_domain=None): """Gets the data and returns it the right format for render.""" |
