mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
CHM Input: resolve absolute links to resource files from the root of the CHM file. Fixes #2023431 [Private bug](https://bugs.launchpad.net/calibre/+bug/2023431)
Previously they would have been ignored or caused an error on Windows.
This commit is contained in:
parent
68f4b773f1
commit
fdb68a1613
@ -104,6 +104,7 @@ class CHMInput(InputFormatPlugin):
|
||||
opts.breadth_first = True
|
||||
htmlinput = HTMLInput(None)
|
||||
htmlinput.set_root_dir_of_input(basedir)
|
||||
htmlinput.root_dir_for_absolute_links = basedir
|
||||
oeb = htmlinput.create_oebbook(htmlpath, basedir, opts, log, mi)
|
||||
return oeb
|
||||
|
||||
|
@ -37,6 +37,7 @@ class HTMLInput(InputFormatPlugin):
|
||||
description = _('Convert HTML and OPF files to an OEB')
|
||||
file_types = {'opf', 'html', 'htm', 'xhtml', 'xhtm', 'shtm', 'shtml'}
|
||||
commit_name = 'html_input'
|
||||
root_dir_for_absolute_links = ''
|
||||
|
||||
options = {
|
||||
OptionRecommendation(name='breadth_first',
|
||||
@ -253,6 +254,9 @@ class HTMLInput(InputFormatPlugin):
|
||||
except:
|
||||
self.log.warn('Failed to decode link %r. Ignoring'%link_)
|
||||
return None, None
|
||||
if self.root_dir_for_absolute_links and link_.startswith('/'):
|
||||
link_ = link_.lstrip('/')
|
||||
base = self.root_dir_for_absolute_links
|
||||
try:
|
||||
l = Link(link_, base if base else os.getcwd())
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user