mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
0fc654b918
commit
e1a0e184c7
@ -3,7 +3,7 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, re
|
import os, re, posixpath
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
|
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
|
||||||
@ -265,10 +265,14 @@ class EPUBInput(InputFormatPlugin):
|
|||||||
|
|
||||||
if len(parts) > 1 and parts[0]:
|
if len(parts) > 1 and parts[0]:
|
||||||
delta = '/'.join(parts[:-1])+'/'
|
delta = '/'.join(parts[:-1])+'/'
|
||||||
|
|
||||||
|
def normpath(x):
|
||||||
|
return posixpath.normpath(delta + elem.get('href'))
|
||||||
|
|
||||||
for elem in opf.itermanifest():
|
for elem in opf.itermanifest():
|
||||||
elem.set('href', delta+elem.get('href'))
|
elem.set('href', normpath(elem.get('href')))
|
||||||
for elem in opf.iterguide():
|
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
|
f = self.rationalize_cover3 if opf.package_version >= 3.0 else self.rationalize_cover2
|
||||||
self.removed_cover = f(opf, log)
|
self.removed_cover = f(opf, log)
|
||||||
|
@ -713,5 +713,6 @@ def main(argv=sys.argv):
|
|||||||
print etree.tostring(doc, pretty_print=True)
|
print etree.tostring(doc, pretty_print=True)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user