mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Viewer: Fix handling of empty self closing tags. Fixes #1083278 (Private bug)
This commit is contained in:
parent
bfe4f5c8b1
commit
10cfd6316f
@ -28,7 +28,7 @@ def self_closing_sub(match):
|
|||||||
tag = match.group(1)
|
tag = match.group(1)
|
||||||
if tag.lower().strip() == 'br':
|
if tag.lower().strip() == 'br':
|
||||||
return match.group()
|
return match.group()
|
||||||
return '<%s %s></%s>'%(match.group(1), match.group(2), match.group(1))
|
return '<%s%s></%s>'%(match.group(1), match.group(2), match.group(1))
|
||||||
|
|
||||||
def load_html(path, view, codec='utf-8', mime_type=None,
|
def load_html(path, view, codec='utf-8', mime_type=None,
|
||||||
pre_load_callback=lambda x:None, path_is_html=False):
|
pre_load_callback=lambda x:None, path_is_html=False):
|
||||||
@ -45,9 +45,7 @@ def load_html(path, view, codec='utf-8', mime_type=None,
|
|||||||
|
|
||||||
html = EntityDeclarationProcessor(html).processed_html
|
html = EntityDeclarationProcessor(html).processed_html
|
||||||
has_svg = re.search(r'<[:a-zA-Z]*svg', html) is not None
|
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-Za-z1-6]+)([^>]*)/\s*>')
|
||||||
self_closing_pat = re.compile(r'<([a-z1-6]+)\s+([^>]+)/>',
|
|
||||||
re.IGNORECASE)
|
|
||||||
html = self_closing_pat.sub(self_closing_sub, html)
|
html = self_closing_pat.sub(self_closing_sub, html)
|
||||||
|
|
||||||
html = re.sub(ur'<\s*title\s*/\s*>', u'', html, flags=re.IGNORECASE)
|
html = re.sub(ur'<\s*title\s*/\s*>', u'', html, flags=re.IGNORECASE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user