From b51d21c5b83b88e8d56dbbbb7600bcbe554d1b07 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 5 Dec 2016 08:21:26 +0100 Subject: [PATCH] [FIX] tools: nbsp+sanitize = write lxml.html.clean module we are using to sanitize html takes either a tree/element or string, and return us an element of the same type. We are passing it an unicode string, and it gives us back an unicode string and if it is possible convert entities to utf-8. This lead to an issue in html inline fields containing an ` ` entity, the entity was converted by the sanitizer to its unicode character (U+00A0). Then, when the field value is loaded to be displayed, the internal value contains U+00A0 characters, but when it is inserted in the page the browser converts them to ` `. Hence in this instance, the internal value is never equal to the displayed value and a write is always triggered even without editing. This commit simple modify the sanitizer so value saved in database contain ` `. closes #14569 opw-689274 --- odoo/tools/mail.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index 1b223b233f5..328fa81465c 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -223,6 +223,8 @@ def html_sanitize(src, silent=True, sanitize_tags=True, sanitize_attributes=Fals cleaned = cleaned.replace('%7C', '|') cleaned = cleaned.replace('<%', '<%') cleaned = cleaned.replace('%>', '%>') + # html considerations so real html content match database value + cleaned.replace(u'\xa0', ' ') except etree.ParserError, e: if 'empty' in str(e): return ""