mirror of
https://github.com/moodle/moodle.git
synced 2025-02-22 02:49:53 +01:00
MDL-84136 filter_tex: Improve sanitization of forbidden items
This commit is contained in:
parent
6e13b652cc
commit
a40e5bad8f
@ -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
|
||||
);
|
||||
|
@ -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'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user