mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 01:14:36 +02:00
Fix #1060 (ePub conversion error)
This commit is contained in:
parent
30fc423489
commit
0b8168258a
2 changed files with 14 additions and 2 deletions
|
|
@ -40,7 +40,7 @@ def __init__(self, path, opts, always_remove=False):
|
|||
self.setup_cli_handler(opts.verbose)
|
||||
self.path = path
|
||||
self.always_remove = always_remove
|
||||
self.base = os.path.splitext(path)[0] + '_split_%d.html'
|
||||
self.base = (os.path.splitext(path)[0].replace('%', '%%') + '_split_%d.html')
|
||||
self.opts = opts
|
||||
self.orig_size = os.stat(content(path)).st_size
|
||||
self.log_info('\tSplitting %s (%d KB)', path, self.orig_size/1024.)
|
||||
|
|
@ -341,7 +341,12 @@ def split(pathtoopf, opts):
|
|||
html_files = []
|
||||
for item in opf.itermanifest():
|
||||
if 'html' in item.get('media-type', '').lower():
|
||||
html_files.append(item.get('href').split('/')[-1])
|
||||
f = item.get('href').split('/')[-1]
|
||||
f2 = f.replace('&', '%26')
|
||||
if not os.path.exists(content(f)) and os.path.exists(content(f2)):
|
||||
f = f2
|
||||
item.set('href', item.get('href').replace('&', '%26'))
|
||||
html_files.append(f)
|
||||
changes = []
|
||||
for f in html_files:
|
||||
if os.stat(content(f)).st_size > opts.profile.flow_size:
|
||||
|
|
|
|||
|
|
@ -238,6 +238,13 @@ def opf_traverse(opf_reader, verbose=0, encoding=None):
|
|||
path = os.path.abspath(item.path)
|
||||
if path not in flat:
|
||||
flat.append(path)
|
||||
for i, path in enumerate(flat):
|
||||
if not os.path.exists(path):
|
||||
path = path.replace('&', '%26')
|
||||
if os.path.exists(path):
|
||||
flat[i] = path
|
||||
for item in opf_reader.itermanifest():
|
||||
item.set('href', item.get('href').replace('&', '%26'))
|
||||
flat = [HTMLFile(path, 0, encoding, verbose) for path in flat]
|
||||
return [f for f in flat if not f.is_binary]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue