From 763ceacafb819a0647a85409f1ea50255d41493d Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Wed, 28 Jan 2009 12:04:22 -0500 Subject: [PATCH] Fix #1720. Fix HTML comments which aren't valid XML comments. --- src/calibre/ebooks/oeb/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 8b505ae4aa..0cfdec6355 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -353,9 +353,13 @@ class Manifest(object): try: data = etree.fromstring(data) except etree.XMLSyntaxError: + # TODO: Factor out HTML->XML coercion self.oeb.logger.warn('Parsing file %r as HTML' % self.href) data = html.fromstring(data) data.attrib.pop('xmlns', None) + for elem in data.iter(tag=etree.Comment): + if elem.text: + elem.text = elem.text.strip('-') data = etree.tostring(data, encoding=unicode) data = etree.fromstring(data) # Force into the XHTML namespace