diff --git a/filter/tex/lib.php b/filter/tex/lib.php index cb9ad37423e..b95591bc091 100644 --- a/filter/tex/lib.php +++ b/filter/tex/lib.php @@ -102,7 +102,9 @@ function filter_tex_sanitize_formula(string $texexp): string { // First, mangle all denied words. $texexp = preg_replace_callback($denylist, function($matches) { - return 'forbiddenkeyword_' . $matches[0]; + // Remove backslashes to make commands impotent. + $noslashes = str_replace('\\', '', $matches[0]); + return 'forbiddenkeyword_' . $noslashes; }, $texexp ); diff --git a/filter/tex/tests/lib_test.php b/filter/tex/tests/lib_test.php index e5bfe29cf37..a718f9c793f 100644 --- a/filter/tex/tests/lib_test.php +++ b/filter/tex/tests/lib_test.php @@ -49,7 +49,7 @@ final class lib_test extends advanced_testcase { ['x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)', 'x\ =\ \frac{\sqrt{144}}{2}\ \times\ (y\ +\ 12)'], ['\usepackage[latin1]{inputenc}', '\usepackage[latin1]{inputenc}'], ['\newcommand{\A}{\verbatiminput}', '\newforbiddenkeyword_command{\A}{\verbatimforbiddenkeyword_input}'], - ['\pdffiledump offset 0 length', 'forbiddenkeyword_\pdffiledump offset 0 length'], + ['\pdffiledump offset 0 length', 'forbiddenkeyword_pdffiledump offset 0 length'], ]; }