From: Antoine Musso Date: Wed, 9 Nov 2011 10:24:54 +0000 (+0000) Subject: Allow \x1b (ascii ESC) in wfDebug() output X-Git-Tag: 1.31.0-rc.0~26626 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=d3c0084895b682dab53040d4eb29303754bc49d1;p=lhc%2Fweb%2Fwiklou.git Allow \x1b (ascii ESC) in wfDebug() output It is a local hack I had to let me pass colored debug message using a local wrapper: function wfDebugGreen($msg) { $color = "\x1b[1;32m"; # Green $reset = "\x1b[1;0m"; wfDebug( $color . $msg . $reset ); } Ideally \x1b should only be kept if it is followed by /(\d+(;\d)?)?+m/ which should match the 'graphic rendering' ANSI escape code. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 82c1cef32a..0017953246 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -710,7 +710,7 @@ function wfDebug( $text, $logonly = false ) { if ( $wgDebugLogFile != '' && !$wgProfileOnly ) { # Strip unprintables; they can switch terminal modes when binary data # gets dumped, which is pretty annoying. - $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text ); + $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1a\x1c-\x1f]!', ' ', $text ); $text = $wgDebugLogPrefix . $text; wfErrorLog( $text, $wgDebugLogFile ); }