From e47da34cbcc5e04e64407ffbc166ba1144563a8a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 16 May 2013 16:22:23 +0900 Subject: [PATCH] fix drag&drop of images with # char (#867) --- aqt/editor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aqt/editor.py b/aqt/editor.py index 71befca4e..b1e97e123 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -14,6 +14,7 @@ from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile, \ import aqt import anki.js from BeautifulSoup import BeautifulSoup +import urllib # fixme: when tab order returns to the webview, the previously focused field # is focused, which is not good when the user is tabbing through the dialog @@ -807,7 +808,7 @@ to a cloze type first, via Edit>Change Note Type.""")) # return a local html link ext = name.split(".")[-1].lower() if ext in pics: - return '' % name + return '' % urllib.quote(name) else: anki.sound.play(name) return '[sound:%s]' % name @@ -1087,6 +1088,8 @@ class EditorWebView(AnkiWebView): ext = url.split(".")[-1].lower() if ext not in pics and ext not in audio: return + if url.lower().startswith("file:/"): + url = urllib.quote(url, safe="/:") # fetch it into a temporary folder self.editor.mw.progress.start(immediate=True) try: