From 3f5f29377f303c9d93dcce4c605d85b791b376be Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 12 Nov 2016 08:00:08 +0530 Subject: [PATCH] Edit Book: Dont fail to rename files on windows if there is a link containing the colon character. Fixes #1641202 [Failure to rename files in ebook editor leads to corrupted ebook](https://bugs.launchpad.net/calibre/+bug/1641202) --- src/calibre/ebooks/oeb/polish/container.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 6ae22da9d0..591cc72111 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -104,10 +104,9 @@ def href_to_name(href, root, base=None): 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. + if iswindows and ':' in href: + # path manipulations on windows fail for paths with : in them, so we + # assume all such paths are invalid/absolute paths. return None fullpath = os.path.join(base, *href.split('/')) return abspath_to_name(fullpath, root)