From c32ea3363208363b7da32cb15c152908ee4c53b5 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 3 Sep 2015 07:52:24 +0200 Subject: [PATCH] [FIX] web_editor, translate: xml translate encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lxml.HTMLParser detect the content encoding by itself if not specified. in the issue leading to this fix, content in a mail with u'\xa4' ( ) was transformed intto u'\xc2\xa4' ( ) since HTMLParser selected the wrong encoding (latin-1 instead of utf-8 for example). this commit specify the known encoding and revert 3d00c210f which was another attempt at this issue. --- addons/web_editor/static/src/js/backend.js | 10 +--------- openerp/tools/translate.py | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index 1516a912b61..52ef2017a14 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -307,15 +307,7 @@ var FieldTextHtml = widget.extend({ return this.editor.save(); } else if (this._dirty_flag && this.editor && this.editor.buildingBlock) { this.editor.buildingBlock.clean_for_save(); - - // escape text nodes for xml saving - var $escaped_el = this.$content.clone(); - $escaped_el.find('*').addBack().not('script,style').contents().each(function(){ - if(this.nodeType == 3) { - this.nodeValue = _.escape(this.nodeValue); - } - }); - this.internal_set_value( $escaped_el.html() ); + this.internal_set_value( this.$content.html() ); } }, destroy: function () { diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index 8cebe086bda..12ead8edb0d 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -271,7 +271,7 @@ def xml_translate(callback, value): return trans.get_done() except etree.ParseError: wrapped = "
%s
" % encode(value) - root = etree.fromstring(wrapped, etree.HTMLParser()) + root = etree.fromstring(wrapped, etree.HTMLParser(encoding='utf-8')) # html > body > div trans.process(root[0][0]) return trans.get_done()[5:-6]