mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04: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
@ -148,7 +148,11 @@ class HTMLFile(object):
|
|||||||
url = match.group(i)
|
url = match.group(i)
|
||||||
if url:
|
if url:
|
||||||
break
|
break
|
||||||
link = self.resolve(url)
|
try:
|
||||||
|
link = self.resolve(url)
|
||||||
|
except ValueError:
|
||||||
|
# Unparseable URL, ignore
|
||||||
|
continue
|
||||||
if link not in self.links:
|
if link not in self.links:
|
||||||
self.links.append(link)
|
self.links.append(link)
|
||||||
|
|
||||||
|
@ -178,7 +178,11 @@ class Serializer(object):
|
|||||||
at the end.
|
at the end.
|
||||||
'''
|
'''
|
||||||
hrefs = self.oeb.manifest.hrefs
|
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:
|
if path and base:
|
||||||
path = base.abshref(path)
|
path = base.abshref(path)
|
||||||
if path and path not in hrefs:
|
if path and path not in hrefs:
|
||||||
|
@ -154,7 +154,11 @@ class Split(object):
|
|||||||
|
|
||||||
def rewrite_links(self, url):
|
def rewrite_links(self, url):
|
||||||
href, frag = urldefrag(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:
|
if href in self.map:
|
||||||
anchor_map = self.map[href]
|
anchor_map = self.map[href]
|
||||||
nhref = anchor_map[frag if frag else None]
|
nhref = anchor_map[frag if frag else None]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user