EPUB Input: Fix incorrect handling of html files that are in a folder above the OPF file. Fixes #1649357 [Private bug](https://bugs.launchpad.net/calibre/+bug/1649357)

This commit is contained in:
Kovid Goyal 2016-12-13 14:40:50 +05:30
parent 0fc654b918
commit e1a0e184c7
2 changed files with 8 additions and 3 deletions

View File

@ -3,7 +3,7 @@ __license__ = 'GPL 3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import os, re
import os, re, posixpath
from itertools import cycle
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
@ -265,10 +265,14 @@ class EPUBInput(InputFormatPlugin):
if len(parts) > 1 and parts[0]:
delta = '/'.join(parts[:-1])+'/'
def normpath(x):
return posixpath.normpath(delta + elem.get('href'))
for elem in opf.itermanifest():
elem.set('href', delta+elem.get('href'))
elem.set('href', normpath(elem.get('href')))
for elem in opf.iterguide():
elem.set('href', delta+elem.get('href'))
elem.set('href', normpath(elem.get('href')))
f = self.rationalize_cover3 if opf.package_version >= 3.0 else self.rationalize_cover2
self.removed_cover = f(opf, log)

View File

@ -713,5 +713,6 @@ def main(argv=sys.argv):
print etree.tostring(doc, pretty_print=True)
return 0
if __name__ == '__main__':
sys.exit(main())