MDL-85152 filter_tex: Update deny list and slash handling

This commit is contained in:
Michael Hawkins 2025-04-10 03:02:27 +08:00 committed by Jun Pataleta
parent 10e93d074b
commit b7a8375e65
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7

View File

@ -84,11 +84,20 @@ function filter_tex_sanitize_formula(string $texexp): string {
'\afterassignment', '\expandafter', '\noexpand', '\special',
'\let', '\futurelet', '\else', '\fi', '\chardef', '\makeatletter', '\afterground',
'\noexpand', '\line', '\mathcode', '\item', '\section', '\mbox', '\declarerobustcommand',
'\ExplSyntaxOn', '\pdffiledump',
'\ExplSyntaxOn', '\pdffiledump', '\mathtex',
];
$allowlist = ['inputenc'];
// Add encoded backslash (\) versions of backslashed items to deny list.
$encodedslashdenylist = array_map(function($value) {
$encoded = str_replace('\\', '\', $value);
// Return an encoded slash version if a slash is found, otherwise null so we can filter it off.
return $encoded != $value ? $encoded : null;
}, $denylist);
$encodedslashdenylist = array_filter($encodedslashdenylist);
$denylist = array_merge($denylist, $encodedslashdenylist);
// Prepare the denylist for regular expression.
$denylist = array_map(function($value){
return '/' . preg_quote($value, '/') . '/i';