From 80c56432ce932b3e2a577be812e59ac000f4dcfa Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 28 Jul 2024 19:47:27 +0200 Subject: [PATCH] Added method to work with arrays --- app/code/core/Mage/Core/Block/Abstract.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index 593d38d2324..7c7d7bda821 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -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 @@ -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 *