From b8d0e1a6b06863e5fe90713fab907935334bc953 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 3 Feb 2012 09:18:31 +0530 Subject: [PATCH] MOBI Input: Handle files that have extra closing tags sprinkled throughtout their markup. Fixes #925833 (prc file fails to read or convert) --- src/calibre/ebooks/mobi/reader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 86f18e2cfe..347e4fda3a 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -364,7 +364,10 @@ class MobiReader(object): self.processed_html = self.remove_random_bytes(self.processed_html) root = fromstring(self.processed_html) if len(root.xpath('body/descendant::*')) < 1: - raise Exception('Failed to parse the markup in this MOBI file') + # There are probably stray s in the markup + self.processed_html = self.processed_html.replace('', + '') + root = fromstring(self.processed_html) if root.tag != 'html': self.log.warn('File does not have opening tag')