From e9907cb9da9ff17b6a13dbdebd162b51153f230d Mon Sep 17 00:00:00 2001 From: Graham Weldon Date: Fri, 10 Dec 2010 12:53:45 +1100 Subject: [PATCH] Made debug() output html-safe strings by default. --- cake/basics.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index cba8c4eae..b80b1b645 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -85,12 +85,12 @@ * Only runs if debug level is greater than zero. * * @param boolean $var Variable to show debug information for. - * @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $showHtml If set to true, the method prints the debug data in a browser-friendly way. * @param boolean $showFrom If set to true, the method prints from where the function was called. * @link http://book.cakephp.org/view/1190/Basic-Debugging * @link http://book.cakephp.org/view/1128/debug */ - function debug($var = false, $showHtml = false, $showFrom = true) { + function debug($var = false, $showHtml = null, $showFrom = true) { if (Configure::read('debug') > 0) { $file = ''; $line = ''; @@ -116,10 +116,14 @@ TEXT; $template = $html; if (php_sapi_name() == 'cli') { $template = $text; + } else { + if ($showHtml === null) { + $showHtml = true; + } } $var = print_r($var, true); if ($showHtml) { - $var = str_replace('<', '<', str_replace('>', '>', $var)); + $var = str_replace(array('<', '>'), array('<', '>'), $var); } printf($template, $file, $line, $var); }