From 583aa2bf4e97f5c4cbfec5a47467d1ee525fa20d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 14 Sep 2014 17:34:00 +0530 Subject: [PATCH] Edit Book: Handle books that contain links that are absolute filenames on windows (i.e. those that start with a drive letter) --- src/calibre/ebooks/oeb/polish/container.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 4a69c52bac..3918f13237 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -364,9 +364,14 @@ class Container(object): # {{{ else: base = os.path.dirname(self.name_to_abspath(base)) purl = urlparse(href) - if purl.scheme or not purl.path or purl.path.startswith('/'): + if purl.scheme or not purl.path: return None href = urlunquote(purl.path) + if href.startswith('/') or (len(href) > 1 and href[1] == ':' and 'a' <= href[0].lower() <= 'z'): + # For paths that start with drive letter os.path.join(base, href) + # will discard base and return href on windows, so we assume that + # such paths are also absolute paths, on all platforms. + return None fullpath = os.path.join(base, *href.split('/')) return self.abspath_to_name(fullpath)