[FIX] web_editor, translate: xml translate encoding
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.
This commit is contained in:
@@ -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 () {
|
||||
|
||||
@@ -271,7 +271,7 @@ def xml_translate(callback, value):
|
||||
return trans.get_done()
|
||||
except etree.ParseError:
|
||||
wrapped = "<div>%s</div>" % 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]
|
||||
|
||||
Reference in New Issue
Block a user