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)

This commit is contained in:
Kovid Goyal 2016-11-12 08:00:08 +05:30
parent 3dd90488dd
commit 3f5f29377f

View File

@ -104,10 +104,9 @@ def href_to_name(href, root, base=None):
if purl.scheme or not purl.path: if purl.scheme or not purl.path:
return None return None
href = urlunquote(purl.path) href = urlunquote(purl.path)
if href.startswith('/') or (len(href) > 1 and href[1] == ':' and 'a' <= href[0].lower() <= 'z'): if iswindows and ':' in href:
# For paths that start with drive letter os.path.join(base, href) # path manipulations on windows fail for paths with : in them, so we
# will discard base and return href on windows, so we assume that # assume all such paths are invalid/absolute paths.
# such paths are also absolute paths, on all platforms.
return None return None
fullpath = os.path.join(base, *href.split('/')) fullpath = os.path.join(base, *href.split('/'))
return abspath_to_name(fullpath, root) return abspath_to_name(fullpath, root)