34
34
error($error_message1);
37
function tex_sanitize_formula($texexp) {
38
/// Check $texexp against blacklist (whitelisting could be more complete but also harder to maintain)
39
$tex_blacklist = array(
40
'include','command','loop','repeat','open','toks','output',
41
'input','catcode','name','^^',
42
'\def','\edef','\gdef','\xdef',
43
'\every','\errhelp','\errorstopmode','\scrollmode','\nonstopmode',
44
'\batchmode','\read','\write','csname','\newhelp','\uppercase',
45
'\lowercase','\relax','\aftergroup',
46
'\afterassignment','\expandafter','\noexpand','\special',
47
'\let', '\futurelet','\else','\fi','\chardef','\makeatletter','\afterground',
48
'\noexpand','\line','\mathcode','\item','\section','\mbox','\declarerobustcommand'
51
return str_ireplace($tex_blacklist, 'forbiddenkeyword', $texexp);
38
54
function tex_filter_get_cmd($pathname, $texexp) {
55
$texexp = tex_sanitize_formula($texexp);
39
56
$texexp = escapeshellarg($texexp);
40
57
$executable = tex_filter_get_executable(false);
68
85
delete_records('cache_filters', 'filter', 'tex');
69
86
delete_records('cache_filters', 'filter', 'algebra');
88
if (!(is_file($CFG->filter_tex_pathlatex) && is_executable($CFG->filter_tex_pathlatex) &&
89
is_file($CFG->filter_tex_pathdvips) && is_executable($CFG->filter_tex_pathdvips) &&
90
is_file($CFG->filter_tex_pathconvert) && is_executable($CFG->filter_tex_pathconvert))) {
91
// LaTeX, dvips or convert are not available, and mimetex can only produce GIFs so...
92
set_config('filter_tex_convertformat', 'gif');