diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-10-02 23:23:21 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-10-02 23:23:21 +0200 |
commit | e90580ee6f97e4be0141679447b0aaec3a0081ea (patch) | |
tree | b29cf8944285f752a576b392502fb850345a13bb /includes/GlobalFunctions.php | |
parent | 24c464c9ee15b0d204c41fcd212975ebc7864904 (diff) |
Update auf 1.13.2
Diffstat (limited to 'includes/GlobalFunctions.php')
-rw-r--r-- | includes/GlobalFunctions.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f5a2660c..26401bb4 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1074,9 +1074,14 @@ function wfPurgeSquidServers ($urlArr) { /** * Windows-compatible version of escapeshellarg() * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() - * function puts single quotes in regardless of OS + * function puts single quotes in regardless of OS. + * + * Also fixes the locale problems on Linux in PHP 5.2.6+ (bug backported to + * earlier distro releases of PHP) */ function wfEscapeShellArg( ) { + wfInitShellLocale(); + $args = func_get_args(); $first = true; $retVal = ''; @@ -2000,6 +2005,7 @@ function wfShellExec( $cmd, &$retval=null ) { $retval = 1; return "Unable to run external programs in safe mode."; } + wfInitShellLocale(); if ( php_uname( 's' ) == 'Linux' ) { $time = intval( ini_get( 'max_execution_time' ) ); @@ -2025,7 +2031,21 @@ function wfShellExec( $cmd, &$retval=null ) { $output = ob_get_contents(); ob_end_clean(); return $output; +} +/** + * Workaround for http://bugs.php.net/bug.php?id=45132 + * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale + */ +function wfInitShellLocale() { + static $done = false; + if ( $done ) return; + $done = true; + global $wgShellLocale; + if ( !wfIniGetBool( 'safe_mode' ) ) { + putenv( "LC_CTYPE=$wgShellLocale" ); + setlocale( LC_CTYPE, $wgShellLocale ); + } } /** |