mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 17:24:20 +02:00
HTML Input: Ignore unparseable URLs instead of crashing on them. Fixes #902372 (HTML convert crashes with " Invalid IPv6 URL" error)
This commit is contained in:
parent
59179fdfe1
commit
ff293d73ac
3 changed files with 15 additions and 3 deletions
|
|
@ -148,7 +148,11 @@ def find_links(self, src):
|
|||
url = match.group(i)
|
||||
if url:
|
||||
break
|
||||
link = self.resolve(url)
|
||||
try:
|
||||
link = self.resolve(url)
|
||||
except ValueError:
|
||||
# Unparseable URL, ignore
|
||||
continue
|
||||
if link not in self.links:
|
||||
self.links.append(link)
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,11 @@ def serialize_href(self, href, base=None):
|
|||
at the end.
|
||||
'''
|
||||
hrefs = self.oeb.manifest.hrefs
|
||||
path, frag = urldefrag(urlnormalize(href))
|
||||
try:
|
||||
path, frag = urldefrag(urlnormalize(href))
|
||||
except ValueError:
|
||||
# Unparseable URL
|
||||
return False
|
||||
if path and base:
|
||||
path = base.abshref(path)
|
||||
if path and path not in hrefs:
|
||||
|
|
|
|||
|
|
@ -154,7 +154,11 @@ def fix_links(self):
|
|||
|
||||
def rewrite_links(self, url):
|
||||
href, frag = urldefrag(url)
|
||||
href = self.current_item.abshref(href)
|
||||
try:
|
||||
href = self.current_item.abshref(href)
|
||||
except ValueError:
|
||||
# Unparseable URL
|
||||
return url
|
||||
if href in self.map:
|
||||
anchor_map = self.map[href]
|
||||
nhref = anchor_map[frag if frag else None]
|
||||
|
|
|
|||
Loading…
Reference in a new issue