From 35764757eb5717022c51ba1b72b4cdb5726c1395 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 22 May 2013 09:19:33 +0900 Subject: [PATCH] we shouldn't quote when adding media - utf8/unicode is valid in the src string, provided we escape quotes - and we escape when setting fields in the editor, leading to double escaping if we do that - and we strip quotes when adding --- aqt/editor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index fd72080c4..e7db09907 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -851,7 +851,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 '' % urllib.quote(name.encode("utf8")) + return '' % name else: anki.sound.play(name) return '[sound:%s]' % name @@ -1147,8 +1147,8 @@ class EditorWebView(AnkiWebView): finally: self.editor.mw.progress.finish() path = unicode(urllib2.unquote(url.encode("utf8")), "utf8") - path = path.replace("#", "") - path = path.replace("%", "") + for badChar in "#%\"": + path = path.replace(badChar, "") path = namedtmp(os.path.basename(path)) file = open(path, "wb") file.write(filecontents)