mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix drag and drop to add files that contain the # character in the filename
This commit is contained in:
parent
a07fcf2fea
commit
1ccddbf41e
@ -143,21 +143,27 @@ def dnd_has_extension(md, extensions):
|
|||||||
urls = [unicode(u.toString()) for u in
|
urls = [unicode(u.toString()) for u in
|
||||||
md.urls()]
|
md.urls()]
|
||||||
purls = [urlparse(u) for u in urls]
|
purls = [urlparse(u) for u in urls]
|
||||||
|
paths = [u2p(x) for x in purls]
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints('URLS:', urls)
|
prints('URLS:', urls)
|
||||||
prints('Paths:', [u2p(x) for x in purls])
|
prints('Paths:', paths)
|
||||||
|
|
||||||
exts = frozenset([posixpath.splitext(u.path)[1][1:].lower() for u in
|
exts = frozenset([posixpath.splitext(u)[1][1:].lower() for u in
|
||||||
purls])
|
paths])
|
||||||
return bool(exts.intersection(frozenset(extensions)))
|
return bool(exts.intersection(frozenset(extensions)))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _u2p(raw):
|
||||||
|
path = raw
|
||||||
|
if iswindows and path.startswith('/'):
|
||||||
|
path = path[1:]
|
||||||
|
return path.replace('/', os.sep)
|
||||||
|
|
||||||
def u2p(url):
|
def u2p(url):
|
||||||
path = url.path
|
path = url.path
|
||||||
if iswindows:
|
ans = _u2p(path)
|
||||||
if path.startswith('/'):
|
if not os.path.exists(ans):
|
||||||
path = path[1:]
|
ans = _u2p(url.path + '#' + url.fragment)
|
||||||
ans = path.replace('/', os.sep)
|
|
||||||
if os.path.exists(ans):
|
if os.path.exists(ans):
|
||||||
return ans
|
return ans
|
||||||
# Try unquoting the URL
|
# Try unquoting the URL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user