From 51121f6e86b513cd2bf3e6d8bd30f66ceea1fb01 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 10 Jun 2013 15:28:34 +0900 Subject: [PATCH] escape image links in clayout and preview as well (#903) --- aqt/browser.py | 2 +- aqt/clayout.py | 4 ++-- aqt/reviewer.py | 3 +-- aqt/utils.py | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aqt/browser.py b/aqt/browser.py index 4f42c16d3..eff923472 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -1044,7 +1044,7 @@ where id in %s""" % ids2str(sf)) ti = lambda x: x base = getBase(self.mw.col) self._previewWeb.stdHtml( - ti(mungeQA(txt)), self.mw.reviewer._styles(), + ti(mungeQA(self.col, txt)), self.mw.reviewer._styles(), bodyClass="card card%d" % (c.ord+1), head=base, js=anki.js.browserSel) clearAudioQueue() diff --git a/aqt/clayout.py b/aqt/clayout.py index 034076723..413f1175d 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -222,11 +222,11 @@ Please create a new card type first.""")) ti = self.maybeTextInput base = getBase(self.mw.col) self.tab['pform'].frontWeb.stdHtml( - ti(mungeQA(c.q(reload=True))), self.mw.reviewer._styles(), + ti(mungeQA(self.mw.col, c.q(reload=True))), self.mw.reviewer._styles(), bodyClass="card card%d" % (c.ord+1), head=base, js=anki.js.browserSel) self.tab['pform'].backWeb.stdHtml( - ti(mungeQA(c.a()), type='a'), self.mw.reviewer._styles(), + ti(mungeQA(self.mw.col, c.a()), type='a'), self.mw.reviewer._styles(), bodyClass="card card%d" % (c.ord+1), head=base, js=anki.js.browserSel) clearAudioQueue() diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 6614bb96e..ebb5eb1e5 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -181,8 +181,7 @@ function _typeAnsPress() { ########################################################################## def _mungeQA(self, buf): - return self.mw.col.media.escapeImages( - self.typeAnsFilter(mungeQA(buf))) + return self.typeAnsFilter(mungeQA(self.mw.col, buf)) def _showQuestion(self): self._reps += 1 diff --git a/aqt/utils.py b/aqt/utils.py index ceb0380bc..8f96286b8 100644 --- a/aqt/utils.py +++ b/aqt/utils.py @@ -317,7 +317,8 @@ def restoreHeader(widget, key): if aqt.mw.pm.profile.get(key): widget.restoreState(aqt.mw.pm.profile[key]) -def mungeQA(txt): +def mungeQA(col, txt): + txt = col.media.escapeImages(txt) txt = stripSounds(txt) # osx webkit doesn't understand font weight 600 txt = re.sub("font-weight: *600", "font-weight:bold", txt)