Fix error when dropping/pasting media file with a hash in its name

This commit is contained in:
David Bailey 2017-08-06 18:03:00 +01:00
parent e40445a9c4
commit d4cf870ff7

View File

@ -544,8 +544,8 @@ to a cloze type first, via Edit>Change Note Type."""))
def _retrieveURL(self, url): def _retrieveURL(self, url):
"Download file into media folder and return local filename or None." "Download file into media folder and return local filename or None."
# urllib doesn't understand percent-escaped utf8, but requires things like # urllib doesn't understand percent-escaped utf8, but requires things like
# '#' to be escaped. we don't try to unquote the incoming URL, because # '#' to be escaped.
# we should only be receiving file:// urls from url mime, which is unquoted url = urllib.parse.unquote(url)
if url.lower().startswith("file://"): if url.lower().startswith("file://"):
url = url.replace("%", "%25") url = url.replace("%", "%25")
url = url.replace("#", "%23") url = url.replace("#", "%23")