Skip to content

Commit

Permalink
Moved method to Mage_Core_Block_Abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Jul 28, 2024
1 parent 83141ac commit dde71e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
14 changes: 0 additions & 14 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,20 +447,6 @@ public static function getStoreConfigFlag($path, $store = null)
}
}


/**
* @param string $path
* @param null|string|bool|int|Mage_Core_Model_Store $store
* @param array|null $allowedTags
* @return Mage_Core_Model_Security_HtmlEscapedString
*/
public static function getStoreConfigObject(string $path, $store = null, ?array $allowedTags = null): Mage_Core_Model_Security_HtmlEscapedString
{
$config = (string) self::getStoreConfig($path, $store);
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
return new Mage_Core_Model_Security_HtmlEscapedString($config, $allowedTags);
}

/**
* Get base URL path by type
*
Expand Down
13 changes: 13 additions & 0 deletions app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,19 @@ public function escapeHtml($data, $allowedTags = null)
return $this->helper('core')->escapeHtml($data, $allowedTags);
}

/**
* Escape html entities
*
* @param string $data
* @param array|null $allowedTags
* @return 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);
}

/**
* Wrapper for standard strip_tags() function with extra functionality for html entities
*
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'] = Mage::getStoreConfigObject('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'] = Mage::getStoreConfigObject('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'] = Mage::getStoreConfigObject('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'] = Mage::getStoreConfigObject('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'] = Mage::getStoreConfigObject('design/header/welcome');
$this->_data['welcome'] = $this->escapeHtmlAsObject((string) Mage::getStoreConfig('design/header/welcome'));
}
}

Expand Down

0 comments on commit dde71e2

Please sign in to comment.