Skip to content

Commit 7677b84

Browse files
committed
Fixed escaping of array/object keys in debug_print_var
1 parent e7457d7 commit 7677b84

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
- Fixed escaping of array/object keys in debug_print_var
10+
911
## [5.5.1] - 2025-05-19
1012
- Fix missing support for loading modifiercompilers from plugin dir in BCPluginsAdapter [#1132](https://github.com/smarty-php/smarty/pull/1132)
1113

src/Extension/DefaultExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $
320320
break;
321321
}
322322
foreach ($var as $curr_key => $curr_val) {
323-
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
323+
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . htmlspecialchars(strtr($curr_key, $_replace)) .
324324
'</b> =&gt; ' .
325325
$this->smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
326326
$depth--;
@@ -338,7 +338,7 @@ public function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $
338338
}
339339
$objects[] = $var;
340340
foreach ($object_vars as $curr_key => $curr_val) {
341-
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) .
341+
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . htmlspecialchars(strtr($curr_key, $_replace)) .
342342
'</b> = ' . $this->smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
343343
$depth--;
344344
}

0 commit comments

Comments
 (0)