From 10cfd6316fe194d6ca2992d108a86e4aca7dbaa1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Nov 2012 13:04:26 +0530 Subject: [PATCH] Viewer: Fix handling of empty self closing tags. Fixes #1083278 (Private bug) --- src/calibre/ebooks/oeb/display/webview.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/oeb/display/webview.py b/src/calibre/ebooks/oeb/display/webview.py index d42d6ae545..dda22a2414 100644 --- a/src/calibre/ebooks/oeb/display/webview.py +++ b/src/calibre/ebooks/oeb/display/webview.py @@ -28,7 +28,7 @@ def self_closing_sub(match): tag = match.group(1) if tag.lower().strip() == 'br': return match.group() - return '<%s %s>'%(match.group(1), match.group(2), match.group(1)) + return '<%s%s>'%(match.group(1), match.group(2), match.group(1)) def load_html(path, view, codec='utf-8', mime_type=None, pre_load_callback=lambda x:None, path_is_html=False): @@ -45,10 +45,8 @@ def load_html(path, view, codec='utf-8', mime_type=None, html = EntityDeclarationProcessor(html).processed_html has_svg = re.search(r'<[:a-zA-Z]*svg', html) is not None - if 'xhtml' in mime_type: - self_closing_pat = re.compile(r'<([a-z1-6]+)\s+([^>]+)/>', - re.IGNORECASE) - html = self_closing_pat.sub(self_closing_sub, html) + self_closing_pat = re.compile(r'<([A-Za-z1-6]+)([^>]*)/\s*>') + html = self_closing_pat.sub(self_closing_sub, html) html = re.sub(ur'<\s*title\s*/\s*>', u'', html, flags=re.IGNORECASE) loading_url = QUrl.fromLocalFile(path)