Fix bug in prefixing scheme
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index 6be53ad..d0c3a42 100644 (file)
@@ -704,7 +704,7 @@ function wfMsgWeirdKey( $key ) {
  * @return string
  */
 function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) {
-       global $wgContLang, $wgMessageCache;
+       global $wgMessageCache;
 
        wfRunHooks('NormalizeMessageKey', array(&$key, &$useDB, &$langCode, &$transform));
        
@@ -1415,14 +1415,19 @@ function wfEscapeShellArg( ) {
                        // Double the backslashes before any double quotes. Escape the double quotes.
                        $tokens = preg_split( '/(\\\\*")/', $arg, -1, PREG_SPLIT_DELIM_CAPTURE );
                        $arg = '';
-                       $delim = false;
+                       $iteration = 0;
                        foreach ( $tokens as $token ) {
-                               if ( $delim ) {
+                               if ( $iteration % 2 == 1 ) {
+                                       // Delimiter, a double quote preceded by zero or more slashes
                                        $arg .= str_replace( '\\', '\\\\', substr( $token, 0, -1 ) ) . '\\"';
-                               } else {
+                               } else if ( $iteration % 4 == 2 ) {
+                                       // ^ in $token will be outside quotes, need to be escaped
+                                       $arg .= str_replace( '^', '^^', $token );
+                               } else { // $iteration % 4 == 0
+                                       // ^ in $token will appear inside double quotes, so leave as is
                                        $arg .= $token;
                                }
-                               $delim = !$delim;
+                               $iteration++;
                        }
                        // Double the backslashes before the end of the string, because
                        // we will soon add a quote
@@ -2055,7 +2060,7 @@ function wfGetNamespaceNotice() {
 }
 
 function wfGetSiteNotice() {
-       global $wgUser, $wgSiteNotice;
+       global $wgUser;
        $fname = 'wfGetSiteNotice';
        wfProfileIn( $fname );
        $siteNotice = '';
@@ -2095,9 +2100,10 @@ function &wfGetMimeMagic() {
  * we'll use sys_get_temp_dir(). The TMPDIR, TMP, and TEMP environment
  * variables are then checked in sequence, and if none are set /tmp is
  * returned as the generic Unix default.
- *
- * NOTE: When possible, use the tempfile() function to create temporary
- * files to avoid race conditions on file creation, etc.
+ * It is common to call it with tempnam().
+ * 
+ * NOTE: When possible, use instead the tmpfile() function to create 
+ * temporary files to avoid race conditions on file creation, etc.
  *
  * @return String
  */