From 38ebbc0a04e587ce53dbd0fa8a447376daf8e735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souk=C3=A9ina=20Bojabza?= Date: Tue, 14 Mar 2023 10:37:40 +0000 Subject: [PATCH] [FIX] website: fix the dynamic snippets rendered content Since commit [1], which updates jQuery to version 3.6.3, when dropping a dynamic snippet (Events, Blog Posts), it appears broken. This happens because in jQuery 3.5.0, the `htmlPrefilter` function (which is called when the dynamic snippet content is rendered) has been modified. The dynamic snippets are broken because auto-closed tags are contained in the data that are fetched from the server and without the jQuery regex to fix them, they are never closed properly, which breaks the rendering. Indeed, the `etree.tostring(...)` function auto-closes the tags of elements having no content when no method is specified as a parameter. This commit prevents auto-closed tags to appear in the data sent by the server when rendering the dynamic snippets, by enforcing the fact that they will be used as HTML. [1]: https://github.com/odoo/odoo/commit/ae1cd3d5bb99b9835501144522b71f152aaf8e34 task-3199318 closes odoo/odoo#116929 X-original-commit: f6cbec8d0116305041f018870ab63e26c8cbef41 Signed-off-by: Quentin Smetz (qsm) --- addons/website/models/website_snippet_filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/models/website_snippet_filter.py b/addons/website/models/website_snippet_filter.py index a856a2a7a8a..614369b0ff4 100644 --- a/addons/website/models/website_snippet_filter.py +++ b/addons/website/models/website_snippet_filter.py @@ -75,7 +75,7 @@ class WebsiteSnippetFilter(models.Model): records=records, is_sample=is_sample, )) - return [etree.tostring(el, encoding='unicode') for el in html.fromstring('%s' % str(content)).getchildren()] + return [etree.tostring(el, encoding='unicode', method='html') for el in html.fromstring('%s' % str(content)).getchildren()] def _prepare_values(self, limit=None, search_domain=None): """Gets the data and returns it the right format for render."""