mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
cgi.escape is deprecated
This commit is contained in:
parent
fccfdef73d
commit
bc65baeff7
6 changed files with 14 additions and 14 deletions
|
@ -2,7 +2,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import cgi
|
import html
|
||||||
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class NoteImporter(Importer):
|
||||||
for n in notes:
|
for n in notes:
|
||||||
for c in range(len(n.fields)):
|
for c in range(len(n.fields)):
|
||||||
if not self.allowHTML:
|
if not self.allowHTML:
|
||||||
n.fields[c] = cgi.escape(n.fields[c])
|
n.fields[c] = html.escape(n.fields[c])
|
||||||
n.fields[c] = n.fields[c].strip()
|
n.fields[c] = n.fields[c].strip()
|
||||||
if not self.allowHTML:
|
if not self.allowHTML:
|
||||||
n.fields[c] = n.fields[c].replace("\n", "<br>")
|
n.fields[c] = n.fields[c].replace("\n", "<br>")
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright: Andreas Klauer <Andreas.Klauer@metamorpher.de>
|
# Copyright: Andreas Klauer <Andreas.Klauer@metamorpher.de>
|
||||||
# License: BSD-3
|
# License: BSD-3
|
||||||
|
|
||||||
import gzip, math, random, time, cgi
|
import gzip, math, random, time, html
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard
|
from anki.importing.noteimp import NoteImporter, ForeignNote, ForeignCard
|
||||||
from anki.stdmodels import addForwardReverse
|
from anki.stdmodels import addForwardReverse
|
||||||
|
@ -50,7 +50,7 @@ class PaukerImporter(NoteImporter):
|
||||||
front = card.findtext('./FrontSide/Text')
|
front = card.findtext('./FrontSide/Text')
|
||||||
back = card.findtext('./ReverseSide/Text')
|
back = card.findtext('./ReverseSide/Text')
|
||||||
note = ForeignNote()
|
note = ForeignNote()
|
||||||
note.fields = [cgi.escape(x.strip()).replace('\n','<br>').replace(' ',' ') for x in [front,back]]
|
note.fields = [html.escape(x.strip()).replace('\n','<br>').replace(' ',' ') for x in [front,back]]
|
||||||
notes.append(note)
|
notes.append(note)
|
||||||
|
|
||||||
# Determine due date for cards.
|
# Determine due date for cards.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import re, os, shutil, cgi
|
import re, os, shutil, html
|
||||||
from anki.utils import checksum, call, namedtmp, tmpdir, isMac, stripHTML
|
from anki.utils import checksum, call, namedtmp, tmpdir, isMac, stripHTML
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
|
@ -135,7 +135,7 @@ def _errMsg(type, texpath):
|
||||||
log = open(namedtmp("latex_log.txt", rm=False)).read()
|
log = open(namedtmp("latex_log.txt", rm=False)).read()
|
||||||
if not log:
|
if not log:
|
||||||
raise Exception()
|
raise Exception()
|
||||||
msg += "<small><pre>" + cgi.escape(log) + "</pre></small>"
|
msg += "<small><pre>" + html.escape(log) + "</pre></small>"
|
||||||
except:
|
except:
|
||||||
msg += _("Have you installed latex and dvipng/dvisvgm?")
|
msg += _("Have you installed latex and dvipng/dvisvgm?")
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import sre_constants
|
import sre_constants
|
||||||
import cgi
|
import html
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
@ -1740,7 +1740,7 @@ update cards set usn=?, mod=?, did=? where id in """ + scids,
|
||||||
t += '''<li><a href=# onclick="pycmd('%s')">%s</a>: %s</a>''' % (
|
t += '''<li><a href=# onclick="pycmd('%s')">%s</a>: %s</a>''' % (
|
||||||
"nid:" + ",".join(str(id) for id in nids),
|
"nid:" + ",".join(str(id) for id in nids),
|
||||||
ngettext("%d note", "%d notes", len(nids)) % len(nids),
|
ngettext("%d note", "%d notes", len(nids)) % len(nids),
|
||||||
cgi.escape(val))
|
html.escape(val))
|
||||||
t += "</ol>"
|
t += "</ol>"
|
||||||
t += "</body></html>"
|
t += "</body></html>"
|
||||||
web.setHtml(t)
|
web.setHtml(t)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import sys, traceback
|
import sys, traceback
|
||||||
import cgi
|
import html
|
||||||
|
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
|
@ -62,7 +62,7 @@ not able to correct them automatically. Please search for 'temp folder' in the \
|
||||||
Anki manual for more information.""")
|
Anki manual for more information.""")
|
||||||
|
|
||||||
def onTimeout(self):
|
def onTimeout(self):
|
||||||
error = cgi.escape(self.pool)
|
error = html.escape(self.pool)
|
||||||
self.pool = ""
|
self.pool = ""
|
||||||
self.mw.progress.clear()
|
self.mw.progress.clear()
|
||||||
if "abortSchemaMod" in error:
|
if "abortSchemaMod" in error:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
import re
|
import re
|
||||||
import cgi
|
import html
|
||||||
import unicodedata as ucd
|
import unicodedata as ucd
|
||||||
import html.parser
|
import html.parser
|
||||||
|
|
||||||
|
@ -416,11 +416,11 @@ Please run Tools>Empty Cards""")
|
||||||
"Diff-corrects the typed-in answer."
|
"Diff-corrects the typed-in answer."
|
||||||
givenElems, correctElems = self.tokenizeComparison(given, correct)
|
givenElems, correctElems = self.tokenizeComparison(given, correct)
|
||||||
def good(s):
|
def good(s):
|
||||||
return "<span class=typeGood>"+cgi.escape(s)+"</span>"
|
return "<span class=typeGood>"+html.escape(s)+"</span>"
|
||||||
def bad(s):
|
def bad(s):
|
||||||
return "<span class=typeBad>"+cgi.escape(s)+"</span>"
|
return "<span class=typeBad>"+html.escape(s)+"</span>"
|
||||||
def missed(s):
|
def missed(s):
|
||||||
return "<span class=typeMissed>"+cgi.escape(s)+"</span>"
|
return "<span class=typeMissed>"+html.escape(s)+"</span>"
|
||||||
if given == correct:
|
if given == correct:
|
||||||
res = good(given)
|
res = good(given)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue