diff --git a/product/ERP5OOo/transforms/html_to_odt.py b/product/ERP5OOo/transforms/html_to_odt.py index ee1d525e8b700f600851287bf1a7923953311c0b..74f374020549e877d076ee759c95ff5d0766a209 100644 --- a/product/ERP5OOo/transforms/html_to_odt.py +++ b/product/ERP5OOo/transforms/html_to_odt.py @@ -32,17 +32,8 @@ class HTMLToOdt: def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs): # Try to recover broken HTML documents, specially regarding encoding used html_node = etree.XML(orig, parser=html_parser) - html_tree = html_node.getroottree() - head = html_tree.find('head') - if head is None: - # This part of code is supposed to be useless - # lxml.html.tostring function with include_meta_content_type - # parameter to True, should do the same things. But it does not. - head = Element('head') - html_node.insert(0, head) - SubElement(head, 'meta', **{'http-equiv': 'Content-Type', - 'content': 'text/html; charset=utf-8'}) - orig = html.tostring(html_node, encoding='utf-8', method='xml') + orig = html.tostring(html_node, encoding='utf-8', method='xml', + include_meta_content_type=True) # workaround a Bug in LibreOffice HTML import filter. # https://bugs.freedesktop.org/show_bug.cgi?id=36080 diff --git a/product/ERP5OOo/transforms/oood_commandtransform.py b/product/ERP5OOo/transforms/oood_commandtransform.py index e70d3d4b0f3586dc96ee5d34030ac20e24049a98..ae5b3c1d1a556ac603fd77221ca14645cc80410a 100644 --- a/product/ERP5OOo/transforms/oood_commandtransform.py +++ b/product/ERP5OOo/transforms/oood_commandtransform.py @@ -194,7 +194,8 @@ class OOOdCommandTransform(commandtransform): parent_node.append(style_node) style_node.attrib.update({'type': 'text/css'}) parent_node.remove(css_link_tag) - xml_output = html.tostring(xml_doc, encoding='utf-8', method='xml') + xml_output = html.tostring(xml_doc, encoding='utf-8', method='xml', + include_meta_content_type=True) xml_output = xml_output.replace('<title/>', '<title></title>') return xml_output