From bdb2d0a5d92b93aa15326250051d7286ca3d2b68 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Mar 2014 21:47:43 +0530 Subject: [PATCH] MOBI Input: Fix empty tags not being handled correctly in rare cases when the markup is bad enough to be parsed only using the HTML 5 algorithm. Fixes #1288430 [Private bug](https://bugs.launchpad.net/calibre/+bug/1288430) --- src/calibre/ebooks/conversion/plugins/mobi_input.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/mobi_input.py b/src/calibre/ebooks/conversion/plugins/mobi_input.py index 27729ff4f0..3a0623da46 100644 --- a/src/calibre/ebooks/conversion/plugins/mobi_input.py +++ b/src/calibre/ebooks/conversion/plugins/mobi_input.py @@ -50,10 +50,13 @@ class MOBIInput(InputFormatPlugin): if isinstance(raw, unicode): raw = raw.encode('utf-8') open(u'debug-raw.html', 'wb').write(raw) + from calibre.ebooks.oeb.base import close_self_closing_tags for f, root in parse_cache.items(): + raw = html.tostring(root, encoding='utf-8', method='xml', + include_meta_content_type=False) + raw = close_self_closing_tags(raw) with open(f, 'wb') as q: - q.write(html.tostring(root, encoding='utf-8', method='xml', - include_meta_content_type=False)) + q.write(raw) accelerators['pagebreaks'] = '//h:div[@class="mbp_pagebreak"]' return mr.created_opf_path