From cc91807ffa3163c583627f8139a938efc8280338 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 May 2012 23:21:38 +0530 Subject: [PATCH] Fix #995553 (Add html injects bad meta http-equiv="Content-Type" tag?) --- src/calibre/ebooks/oeb/parse_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/parse_utils.py b/src/calibre/ebooks/oeb/parse_utils.py index 08bb3ee2df..88dbb2ae56 100644 --- a/src/calibre/ebooks/oeb/parse_utils.py +++ b/src/calibre/ebooks/oeb/parse_utils.py @@ -361,9 +361,11 @@ def parse_html(data, log=None, decoder=None, preprocessor=None, # Remove any encoding-specifying elements for meta in META_XP(data): meta.getparent().remove(meta) - etree.SubElement(head, XHTML('meta'), - attrib={'http-equiv': 'Content-Type', - 'content': '%s; charset=utf-8' % XHTML_NS}) + meta = etree.SubElement(head, XHTML('meta'), + attrib={'http-equiv': 'Content-Type'}) + meta.set('content', 'text/html; charset=utf-8') # Ensure content is second + # attribute + # Ensure has a if not xpath(data, '/h:html/h:body'): body = xpath(data, '//h:body')