~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

Viewing changes to filter/tex/lib.php

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php  //$Id: lib.php,v 1.1.2.4 2007/12/25 10:03:17 skodak Exp $
 
1
<?php  //$Id: lib.php,v 1.1.2.7 2010/04/10 00:17:45 iarenaza Exp $
2
2
 
3
3
function tex_filter_get_executable($debug=false) {
4
4
    global $CFG;
34
34
    error($error_message1);
35
35
}
36
36
 
 
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'
 
49
    );
 
50
 
 
51
    return  str_ireplace($tex_blacklist, 'forbiddenkeyword', $texexp);
 
52
}
37
53
 
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);
41
58
 
67
84
 
68
85
    delete_records('cache_filters', 'filter', 'tex');
69
86
    delete_records('cache_filters', 'filter', 'algebra');
 
87
 
 
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');
 
93
    }
70
94
}
71
95
 
72
96
?>