Skip to content

Commit

Permalink
Added method to work with arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Jul 28, 2024
1 parent b95a4f5 commit 80c5643
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ public function escapeHtml($data, $allowedTags = null)
* Escape html entities
*
* @param string $data
* @param array|null $allowedTags
* @param string[]|null $allowedTags
* @return Mage_Core_Model_Security_HtmlEscapedString
*/
public function escapeHtmlAsObject(string $data, ?array $allowedTags = null): Mage_Core_Model_Security_HtmlEscapedString
Expand All @@ -1210,6 +1210,24 @@ public function escapeHtmlAsObject(string $data, ?array $allowedTags = null): Ma
return new Mage_Core_Model_Security_HtmlEscapedString($data, $allowedTags);
}

/**
* Escape html entities
*
* @param string[] $data
* @param string[]|null $allowedTags
* @return Mage_Core_Model_Security_HtmlEscapedString[]
*/
public function escapeHtmlArrayAsObject(array $data, ?array $allowedTags = null): array
{
$result = [];
foreach ($data as $kay => $string) {
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
$result[$kay] = new Mage_Core_Model_Security_HtmlEscapedString($string, $allowedTags);
}

return $result;
}

/**
* Wrapper for standard strip_tags() function with extra functionality for html entities
*
Expand Down

0 comments on commit 80c5643

Please sign in to comment.