Skip to content

Commit 5466c2d

Browse files
committed
Make attribute handling more robust
1 parent 10bd5d9 commit 5466c2d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/TgUtils/Html.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class Html {
1616
*/
1717
public static function renderStartTag($tagName, $attributes = array(), $closeTag = FALSE) {
1818
$rc = '<'.$tagName;
19-
foreach ($attributes AS $name => $value) {
20-
if (is_array($value)) $value = implode(' ', $value);
21-
if (is_string($value) && trim($value) != '') {
22-
$rc .= ' '.$name.'="'.htmlspecialchars($value).'"';
19+
if (is_array($attributes)) {
20+
foreach ($attributes AS $name => $value) {
21+
if (is_array($value)) $value = implode(' ', $value);
22+
if (is_string($value) && trim($value) != '') {
23+
$rc .= ' '.$name.'="'.htmlspecialchars($value).'"';
24+
}
2325
}
2426
}
25-
2627
if ($closeTag) $rc .= '/';
2728
$rc .= '>';
2829
return $rc;

0 commit comments

Comments
 (0)