Skip to content

Commit

Permalink
Reverted renaming, updated docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Aug 26, 2024
1 parent c7273a3 commit 12097cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,30 +1198,34 @@ public function escapeHtml($data, $allowedTags = null)
}

/**
* Escape html entities
* Wrapper for escapeHtml() function with keeping original value
*
* @param string $data
* @param string[]|null $allowedTags
* @return Mage_Core_Model_Security_HtmlEscapedString
*
* @see Mage_Core_Model_Security_HtmlEscapedString::getUnescapedValue()
*/
public function getCoreModelSecurityHtmlEscapedString(string $data, ?array $allowedTags = null): Mage_Core_Model_Security_HtmlEscapedString
public function escapeHtmlAsObject(string $data, ?array $allowedTags = null): Mage_Core_Model_Security_HtmlEscapedString
{
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
return new Mage_Core_Model_Security_HtmlEscapedString($data, $allowedTags);
}

/**
* Escape html entities
* Wrapper for escapeHtml() function with keeping original value
*
* @param string[] $data
* @param string[]|null $allowedTags
* @return Mage_Core_Model_Security_HtmlEscapedString[]
*
* @see Mage_Core_Model_Security_HtmlEscapedString::getUnescapedValue()
*/
public function getCoreModelSecurityHtmlArrayEscapedString(array $data, ?array $allowedTags = null): array
public function escapeHtmlArrayAsObject(array $data, ?array $allowedTags = null): array
{
$result = [];
foreach ($data as $key => $string) {
$result[$key] = $this->getCoreModelSecurityHtmlEscapedString($string, $allowedTags);
$result[$key] = $this->escapeHtmlAsObject($string, $allowedTags);
}

return $result;
Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Core/Model/Security/HtmlEscapedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function __construct(string $originalValue, ?array $allowedTags = null)
}

/**
* Get escaped html entities
*
* @return string
*/
public function __toString(): string
Expand All @@ -55,6 +57,8 @@ public function __toString(): string
}

/**
* Get un-escaped html entities
*
* @return string
*/
public function getUnescapedValue(): string
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Page/Block/Html/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function setLogo($logo_src, $logo_alt)
public function getLogoSrc()
{
if (empty($this->_data['logo_src'])) {
$this->_data['logo_src'] = $this->getCoreModelSecurityHtmlEscapedString((string) Mage::getStoreConfig('design/header/logo_src'));
$this->_data['logo_src'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/logo_src'));
}
return $this->getSkinUrl($this->_data['logo_src']);
}
Expand All @@ -68,7 +68,7 @@ public function getLogoSrc()
public function getLogoSrcSmall()
{
if (empty($this->_data['logo_src_small'])) {
$this->_data['logo_src_small'] = $this->getCoreModelSecurityHtmlEscapedString((string) Mage::getStoreConfig('design/header/logo_src_small'));
$this->_data['logo_src_small'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/logo_src_small'));
}
return $this->getSkinUrl($this->_data['logo_src_small']);
}
Expand All @@ -79,7 +79,7 @@ public function getLogoSrcSmall()
public function getLogoAlt()
{
if (empty($this->_data['logo_alt'])) {
$this->_data['logo_alt'] = $this->getCoreModelSecurityHtmlEscapedString((string) Mage::getStoreConfig('design/header/logo_alt'));
$this->_data['logo_alt'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/logo_alt'));
}
return $this->_data['logo_alt'];
}
Expand All @@ -97,7 +97,7 @@ public function getWelcome()
if (Mage::isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml(Mage::getSingleton('customer/session')->getCustomer()->getName()));
} else {
$this->_data['welcome'] = $this->getCoreModelSecurityHtmlEscapedString((string) Mage::getStoreConfig('design/header/welcome'));
$this->_data['welcome'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/welcome'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Page/Block/Html/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function _toHtml()
if (Mage::isInstalled() && $this->_getSession()->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', $this->escapeHtml($this->_getSession()->getCustomer()->getName()));
} else {
$this->_data['welcome'] = $this->getCoreModelSecurityHtmlEscapedString((string) Mage::getStoreConfig('design/header/welcome'));
$this->_data['welcome'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/welcome'));
}
}

Expand Down

0 comments on commit 12097cc

Please sign in to comment.