From 1f0f8d062c8122b46f22e06f730272275fdbd4f8 Mon Sep 17 00:00:00 2001 From: mohrt Date: Mon, 21 Apr 2003 16:17:26 +0000 Subject: [PATCH] fix escapement of special chars in key values of debug console --- NEWS | 2 ++ libs/plugins/modifier.debug_print_var.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1d78ca95..281d3c40 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - fix escapement of special chars for key vals in debug + console (Monte) - fixed debug timing logic for config_load (Tom Sommer, Monte) - all in-code doc comments converted to phpDocumentor format (Greg) - moved strip from smarty core to plugin (Monte) diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php index b5fdad42..c5e2f521 100644 --- a/libs/plugins/modifier.debug_print_var.php +++ b/libs/plugins/modifier.debug_print_var.php @@ -21,11 +21,13 @@ */ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { + $_search = array("!\n!", "!\r!", "!\t!"); + $_replace = array('\n', '\r', '\t'); if (is_array($var)) { $results = "Array (".count($var).")"; foreach ($var as $curr_key => $curr_val) { $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length); - $results .= '
\r'.str_repeat(' ', $depth*2)."$curr_key => $return"; + $results .= '
\r'.str_repeat(' ', $depth*2)."".preg_replace($_search, $_replace, $curr_key)." => $return"; } return $results; } else if (is_object($var)) { @@ -45,7 +47,7 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) } else { $results = $var; } - $results = preg_replace("![\r\t\n]!", " ", $results); + $results = preg_replace($_search, $_replace, $results); $results = htmlspecialchars($results); return $results; }