From 30a2525d3430b8df4818fd454638779450bfc0d9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Jul 2015 16:10:27 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/oeb/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 158aa4b857..148eba9d47 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -1054,9 +1054,10 @@ class Manifest(object): return href if '/' not in self.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 = target.split('/') + index = 0 for index in xrange(min(len(base), len(target))): if base[index] != target[index]: break