Index: trunk/extensions/Math/Math.body.php |
— | — | @@ -10,6 +10,17 @@ |
11 | 11 | * @ingroup Parser |
12 | 12 | */ |
13 | 13 | |
| 14 | +if ( !function_exists('wfEscapeSingleQuotes') ) { |
| 15 | + /** |
| 16 | + * Escapes a string with single quotes for a UNIX shell. |
| 17 | + * It's equivalente to escapeshellarg() in UNIX, but also |
| 18 | + * working in Windows, where we need it for cygwin shell. |
| 19 | + */ |
| 20 | + function wfEscapeSingleQuotes( $str ) { |
| 21 | + return "'" . str_replace( "'", "'\\''", $str ) . "'"; |
| 22 | + } |
| 23 | +} |
| 24 | + |
14 | 25 | /** |
15 | 26 | * Takes LaTeX fragments, sends them to a helper program (texvc) for rendering |
16 | 27 | * to rasterized PNG and HTML and MathML approximations. An appropriate |
— | — | @@ -65,11 +76,11 @@ |
66 | 77 | return $this->_error( 'math_notexvc' ); |
67 | 78 | } |
68 | 79 | $cmd = $wgTexvc . ' ' . |
69 | | - escapeshellarg( $wgTmpDirectory ).' '. |
70 | | - escapeshellarg( $wgTmpDirectory ).' '. |
71 | | - escapeshellarg( $this->tex ).' '. |
72 | | - escapeshellarg( 'UTF-8' ).' '. |
73 | | - escapeshellarg( $wgTexvcBackgroundColor ); |
| 80 | + wfEscapeSingleQuotes( $wgTmpDirectory ) . ' '. |
| 81 | + wfEscapeSingleQuotes( $wgTmpDirectory ) . ' '. |
| 82 | + wfEscapeSingleQuotes( $this->tex ) . ' '. |
| 83 | + wfEscapeSingleQuotes( 'UTF-8' ) . ' '. |
| 84 | + wfEscapeSingleQuotes( $wgTexvcBackgroundColor ); |
74 | 85 | |
75 | 86 | if ( wfIsWindows() ) { |
76 | 87 | # Invoke it within cygwin sh, because texvc expects sh features in its default shell |