From b2cf86b905ba953de11479f3e6446678a9741511 Mon Sep 17 00:00:00 2001 From: Arne Ludwig Date: Thu, 30 Jul 2015 11:44:47 +0200 Subject: [PATCH] Don't mind LaTeX commands beginning with bad names --- anki/latex.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/anki/latex.py b/anki/latex.py index 0931e8cde..9793c55fc 100644 --- a/anki/latex.py +++ b/anki/latex.py @@ -78,9 +78,12 @@ def _buildImg(col, latex, fname, model): latex = latex.encode("utf8") # it's only really secure if run in a jail, but these are the most common tmplatex = latex.replace("\\includegraphics", "") - for bad in ("write18", "\\readline", "\\input", "\\include", "\\catcode", - "\\openout", "\\write", "\\loop", "\\def", "\\shipout"): - if bad in tmplatex: + for bad in ("write18", "\\\\readline", "\\\\input", "\\\\include", + "\\\\catcode", "\\\\openout", "\\\\write", "\\\\loop", + "\\\\def", "\\\\shipout"): + # don't mind if the sequence is only part of a command + bad_re = bad + "[^a-zA-Z]" + if re.search(bad_re, tmplatex): return _("""\ For security reasons, '%s' is not allowed on cards. You can still use \ it by placing the command in a different package, and importing that \