[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#66883 X-original-commit: 38983d123d171ac3cc1efacd99d9776f0ed08734 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
committed by
Nicolas Lempereur
parent
b5e158c3c6
commit
f09c84c022
@@ -335,7 +335,7 @@ class IrUiView(models.Model):
|
||||
name = self._find_available_name(name, used_names)
|
||||
|
||||
# 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,
|
||||
|
||||
@@ -71,7 +71,7 @@ class WebsiteSnippetFilter(models.Model):
|
||||
is_sample=is_sample,
|
||||
to_generic=self._to_generic,
|
||||
)).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."""
|
||||
|
||||
@@ -372,7 +372,7 @@ class QWeb(object):
|
||||
|
||||
if isinstance(document, etree._Element):
|
||||
element = document
|
||||
document = etree.tostring(document)
|
||||
document = etree.tostring(document, encoding='utf-8')
|
||||
elif not document.strip().startswith('<') and os.path.exists(document):
|
||||
element = etree.parse(document).getroot()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user