escape path to images

This commit is contained in:
Damien Elmes 2008-12-05 12:54:16 +09:00
parent 6f59cc7cd2
commit 876c16d413

View file

@ -8,7 +8,7 @@ from anki.sound import playFromText, stripSounds
from anki.latex import renderLatex, stripLatex from anki.latex import renderLatex, stripLatex
from ankiqt import ui from ankiqt import ui
import re, os, sys import re, os, sys, urllib
import ankiqt import ankiqt
def openLink(link): def openLink(link):
@ -178,7 +178,9 @@ def mungeQA(deck, txt):
prefix = u"file:///" prefix = u"file:///"
else: else:
prefix = u"file://" 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 return 'img src="%s"' % src
txt = re.sub('img src="(.*?)"', quote, txt) txt = re.sub('img src="(.*?)"', quote, txt)
return txt return txt