mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
removed '\r' from debug_print_vars' output
properly escape vars in javascript-version of debug.tpl
This commit is contained in:
@@ -47,13 +47,13 @@
|
||||
{/section}
|
||||
_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>");
|
||||
{section name=vars loop=$_debug_keys}
|
||||
_smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>");
|
||||
_smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
|
||||
{sectionelse}
|
||||
_smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>");
|
||||
{/section}
|
||||
_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>");
|
||||
{section name=config_vars loop=$_debug_config_keys}
|
||||
_smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var}</font></tt></td></tr>");
|
||||
_smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
|
||||
{sectionelse}
|
||||
_smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");
|
||||
{/section}
|
||||
|
@@ -21,13 +21,12 @@
|
||||
*/
|
||||
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
||||
{
|
||||
$_search = array("!\n!", "!\r!", "!\t!");
|
||||
$_replace = array('<i>\n</i>', '<i>\r</i>', '<i>\t</i>');
|
||||
$_replace = array("\n"=>'<i>\n</i>', "\r"=>'<i>\r</i>', "\t"=>'<i>\t</i>');
|
||||
if (is_array($var)) {
|
||||
$results = "<b>Array (".count($var).")</b>";
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
|
||||
$results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>".preg_replace($_search, $_replace, $curr_key)."</b> => $return";
|
||||
$results .= "<br>".str_repeat(' ', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> => $return";
|
||||
}
|
||||
return $results;
|
||||
} else if (is_object($var)) {
|
||||
@@ -35,7 +34,7 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
||||
$results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
|
||||
$results .= '<br>\r'.str_repeat(' ', $depth*2)."<b>$curr_key</b> => $return";
|
||||
$results .= "<br>".str_repeat(' ', $depth*2)."<b>$curr_key</b> => $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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user