Conversion: Fix incorrect relative URLs being generated when an HTML or CSS file is placed higher in the folder hierarchy than the opf file. Fixes #1474287 [ePUB->AZW3: incorrect styles on inline ToC](https://bugs.launchpad.net/calibre/+bug/1474287)

This commit is contained in:
Kovid Goyal 2015-07-14 16:10:27 +05:30
parent 38028aa0d3
commit 30a2525d34

View File

@ -1054,9 +1054,10 @@ class Manifest(object):
return href return href
if '/' not in self.href: if '/' not in self.href:
return href return href
base = os.path.dirname(self.href).split('/') base = filter(None, os.path.dirname(os.path.normpath(self.href)).replace(os.sep, '/').split('/'))
target, frag = urldefrag(href) target, frag = urldefrag(href)
target = target.split('/') target = target.split('/')
index = 0
for index in xrange(min(len(base), len(target))): for index in xrange(min(len(base), len(target))):
if base[index] != target[index]: if base[index] != target[index]:
break break