From 876c16d4130efbd0c8ae90278b0363f9fa7f2066 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 5 Dec 2008 12:54:16 +0900 Subject: [PATCH] escape path to images --- ankiqt/ui/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py index 9597f0402..cfa5b7458 100644 --- a/ankiqt/ui/utils.py +++ b/ankiqt/ui/utils.py @@ -8,7 +8,7 @@ from anki.sound import playFromText, stripSounds from anki.latex import renderLatex, stripLatex from ankiqt import ui -import re, os, sys +import re, os, sys, urllib import ankiqt def openLink(link): @@ -178,7 +178,9 @@ def mungeQA(deck, txt): prefix = u"file:///" else: prefix = u"file://" - src = prefix + os.path.join(deck.mediaDir(create=True), match) + src = prefix + unicode( + urllib.quote(os.path.join(deck.mediaDir( + create=True), match).encode("utf-8")), "utf-8") return 'img src="%s"' % src txt = re.sub('img src="(.*?)"', quote, txt) return txt