diff --git a/libs/debug.tpl b/libs/debug.tpl
index fb1e2051..01265fb4 100644
--- a/libs/debug.tpl
+++ b/libs/debug.tpl
@@ -47,13 +47,13 @@
{/section}
_smarty_console.document.write("
assigned template variables: |
");
{section name=vars loop=$_debug_keys}
- _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim} | {$_debug_vals[vars]|@debug_print_var} |
");
+ _smarty_console.document.write("{ldelim}${$_debug_keys[vars]}{rdelim} | {$_debug_vals[vars]|@debug_print_var|escape:javascript} |
");
{sectionelse}
_smarty_console.document.write("no template variables assigned |
");
{/section}
_smarty_console.document.write("assigned config file variables (outer template scope): |
");
{section name=config_vars loop=$_debug_config_keys}
- _smarty_console.document.write("{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim} | {$_debug_config_vals[config_vars]|@debug_print_var} |
");
+ _smarty_console.document.write("{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim} | {$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript} |
");
{sectionelse}
_smarty_console.document.write("no config vars assigned |
");
{/section}
diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php
index cbd7b980..35283113 100644
--- a/libs/plugins/modifier.debug_print_var.php
+++ b/libs/plugins/modifier.debug_print_var.php
@@ -21,13 +21,12 @@
*/
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
- $_search = array("!\n!", "!\r!", "!\t!");
- $_replace = array('\n', '\r', '\t');
+ $_replace = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\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)."".preg_replace($_search, $_replace, $curr_key)." => $return";
+ $results .= "
".str_repeat(' ', $depth*2)."".strtr($curr_key, $_replace)." => $return";
}
return $results;
} else if (is_object($var)) {
@@ -35,7 +34,7 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
$results = "".get_class($var)." Object (".count($object_vars).")";
foreach ($object_vars 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 .= "
".str_repeat(' ', $depth*2)."$curr_key => $return";
}
return $results;
} else {
@@ -48,7 +47,7 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
$results = $var;
}
$results = htmlspecialchars($results);
- $results = preg_replace($_search, $_replace, $results);
+ $results = strtr($results, $_replace);
return $results;
}
}