Skip to content

Commit

Permalink
fix deprecated and json escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
jturbide committed Feb 21, 2024
1 parent 22066de commit 0a747bd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,30 +109,31 @@ public static function implodeSprintf(array $array, string $format = '%s', ?stri
public static function escapeParam($value = null, ?string $attr = null, string $glue = ' '): array
{
$escaper = self::getEscaperService();
assert($escaper instanceof \Zemit\Html\Escaper);

$attr = $escaper->escapeHtmlAttr($attr);
$attr = $escaper->attributes($attr);
switch ($attr) {
case 'css':
case 'style':
$value = $escaper->escapeCss($value);
$value = $escaper->css($value);
break;

case 'js':
case 'javascript':
$value = $escaper->escapeJs($value);
$value = $escaper->js($value);
break;

case 'href':
case 'url':
$value = $escaper->escapeUrl($value);
$value = $escaper->url($value);
break;

default:
// array escaper
if (is_array($value)) {
if (isset($value[0]) && is_string($value[0])) {
foreach ($value as &$v) {
$v = $escaper->escapeHtmlAttr($v);
$v = $escaper->attributes($v);
}
$value = implode($glue, $value);
}
Expand All @@ -148,7 +149,7 @@ public static function escapeParam($value = null, ?string $attr = null, string $
}
// default escaper
else {
$value = $escaper->escapeHtmlAttr($value);
$value = $escaper->attributes($value);
}
break;
}
Expand Down

0 comments on commit 0a747bd

Please sign in to comment.