From e90580ee6f97e4be0141679447b0aaec3a0081ea Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 2 Oct 2008 23:23:21 +0200 Subject: Update auf 1.13.2 --- includes/GlobalFunctions.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'includes/GlobalFunctions.php') 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 ); + } } /** -- cgit v1.2.3-54-g00ecf