MDL-71240 filter_tex: Support paranoid mode for openin_any in latex

This commit is contained in:
Shamim Rezaie
2021-09-07 00:14:39 +02:00
committed by Jenkins
parent 0cd2cbccfb
commit cd7fa2e513
2 changed files with 9 additions and 6 deletions
+5 -2
View File
@@ -114,11 +114,14 @@
$convertformat = 'png';
}
$filename = str_replace(".{$convertformat}", '', $filename);
$tex = "{$this->temp_dir}/$filename.tex";
$tex = "$filename.tex"; // Absolute paths won't work with openin_any = p setting.
$dvi = "{$this->temp_dir}/$filename.dvi";
$ps = "{$this->temp_dir}/$filename.ps";
$img = "{$this->temp_dir}/$filename.{$convertformat}";
// Change directory to temp dir so that we can work with relative paths.
chdir($this->temp_dir);
// turn the latex doc into a .tex file in the temp area
$fh = fopen( $tex, 'w' );
fputs( $fh, $doc );
@@ -126,7 +129,7 @@
// run latex on document
$command = "$pathlatex --interaction=nonstopmode --halt-on-error $tex";
chdir( $this->temp_dir );
if ($this->execute($command, $log)) { // It allways False on Windows
// return false;
}
+4 -4
View File
@@ -238,12 +238,15 @@
$output .= "<p>base filename for expression is '$md5'</p>\n";
// temporary paths
$tex = "$latex->temp_dir/$md5.tex";
$tex = "$md5.tex"; // Absolute paths won't work with openin_any = p setting.
$dvi = "$latex->temp_dir/$md5.dvi";
$ps = "$latex->temp_dir/$md5.ps";
$convertformat = get_config('filter_tex', 'convertformat');
$img = "$latex->temp_dir/$md5.{$convertformat}";
// Change directory to temp dir so that we can work with relative paths.
chdir($latex->temp_dir);
// put the expression as a file into the temp area
$expression = html_entity_decode($expression);
$output .= "<p>Processing TeX expression:</p><pre>$expression</pre>\n";
@@ -252,9 +255,6 @@
fputs($fh, $doc);
fclose($fh);
// cd to temp dir
chdir($latex->temp_dir);
// step 1: latex command
$pathlatex = escapeshellarg($pathlatex);
$cmd = "$pathlatex --interaction=nonstopmode --halt-on-error $tex";