Merge pull request #193 from techdavid/fix-paste-url-with-hash

Fix error when dropping/pasting media file with a hash in its name
This commit is contained in:
Damien Elmes 2017-08-07 12:19:30 +10:00 committed by GitHub
commit 27f992c6b4

View file

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