https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103473

Revision: 103473
Author:   platonides
Date:     2011-11-17 16:25:25 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
wfEscapeSingleQuotes() change proposed by Ralf Lederle in 
https://bugzilla.wikimedia.org/show_bug.cgi?id=13518#c11
For Bug 13518 - <math> does not work (wrong shell escaping under Windows)

Modified Paths:
--------------
    trunk/extensions/Math/Math.body.php

Modified: trunk/extensions/Math/Math.body.php
===================================================================
--- trunk/extensions/Math/Math.body.php 2011-11-17 16:24:30 UTC (rev 103472)
+++ trunk/extensions/Math/Math.body.php 2011-11-17 16:25:25 UTC (rev 103473)
@@ -10,6 +10,17 @@
  * @ingroup Parser
  */
 
+if ( !function_exists('wfEscapeSingleQuotes') ) {
+       /**
+        * Escapes a string with single quotes for a UNIX shell.
+        * It's equivalente to escapeshellarg() in UNIX, but also 
+        * working in Windows, where we need it for cygwin shell.
+        */
+       function wfEscapeSingleQuotes( $str ) {
+               return "'" . str_replace( "'", "'\\''", $str ) . "'";
+       }
+}
+
 /**
  * Takes LaTeX fragments, sends them to a helper program (texvc) for rendering
  * to rasterized PNG and HTML and MathML approximations. An appropriate
@@ -65,11 +76,11 @@
                                return $this->_error( 'math_notexvc' );
                        }
                        $cmd = $wgTexvc . ' ' .
-                                       escapeshellarg( $wgTmpDirectory ).' '.
-                                       escapeshellarg( $wgTmpDirectory ).' '.
-                                       escapeshellarg( $this->tex ).' '.
-                                       escapeshellarg( 'UTF-8' ).' '.
-                                       escapeshellarg( $wgTexvcBackgroundColor 
);
+                                       wfEscapeSingleQuotes( $wgTmpDirectory ) 
. ' '.
+                                       wfEscapeSingleQuotes( $wgTmpDirectory ) 
. ' '.
+                                       wfEscapeSingleQuotes( $this->tex ) . ' 
'.
+                                       wfEscapeSingleQuotes( 'UTF-8' ) . ' '.
+                                       wfEscapeSingleQuotes( 
$wgTexvcBackgroundColor );
 
                        if ( wfIsWindows() ) {
                                # Invoke it within cygwin sh, because texvc 
expects sh features in its default shell


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to