Skip to content

Commit

Permalink
Updates for 20.10.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Jul 27, 2024
1 parent 370db1d commit ae5df65
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function canSendCommentEmail()
/**
* Replace links in string
*
* @param array|string $data
* @param null|array $allowedTags
* @return string
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*/
public function escapeHtml($data, $allowedTags = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function isCustomerNotificationNotApplicable(Mage_Sales_Model_Order_Statu
/**
* Replace links in string
*
* @param array|string $data
* @param null|array $allowedTags
* @return string
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*/
public function escapeHtml($data, $allowedTags = null)
{
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Adminhtml/Helper/Sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public function applySalableProductTypesFilter($collection)
/**
* Escape string preserving links
*
* @param array|string $data
* @param null|array $allowedTags
* @return string
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*/
public function escapeHtmlWithLinks($data, $allowedTags = null)
{
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -1185,9 +1185,9 @@ public function htmlEscape($data, $allowedTags = null)
/**
* Escape html entities
*
* @param string|array $data
* @param array $allowedTags
* @return string
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*/
public function escapeHtml($data, $allowedTags = null)
{
Expand Down
19 changes: 10 additions & 9 deletions app/code/core/Mage/Core/Helper/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ public function __()
}

/**
* @param array $data
* @param array $allowedTags
* @return mixed
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*
* @see self::escapeHtml()
* @deprecated after 1.4.0.0-rc1
*/
Expand All @@ -192,9 +193,9 @@ public function htmlEscape($data, $allowedTags = null)
/**
* Escape html entities
*
* @param string|array $data
* @param array $allowedTags
* @return mixed
* @param string|string[] $data
* @param array|null $allowedTags
* @return null|string|string[]
*/
public function escapeHtml($data, $allowedTags = null)
{
Expand Down Expand Up @@ -244,7 +245,7 @@ function ($matches) {
* Wrapper for standard strip_tags() function with extra functionality for html entities
*
* @param string $data
* @param string $allowableTags
* @param null|string|string[] $allowableTags
* @param bool $escape
* @return string
*/
Expand Down Expand Up @@ -320,9 +321,9 @@ public function escapeScriptIdentifiers($data)
/**
* Escape quotes in java script
*
* @param mixed $data
* @param string|string[] $data
* @param string $quote
* @return mixed
* @return string|string[]
*/
public function jsQuoteEscape($data, $quote = '\'')
{
Expand Down
33 changes: 31 additions & 2 deletions app/code/core/Mage/Core/Model/Security/HtmlEscapedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,35 @@
declare(strict_types=1);

/**
* OpenMage
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available at https://opensource.org/license/osl-3-0-php
*
* @category Mage
* @package Mage_Core
* @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Wrapper to escape value und keep the original value
*
* @category Mage
* @package Mage_Core
*/
class Mage_Core_Model_Security_HtmlEscapedString implements Stringable
{
protected $originalValue;
protected $allowedTags;
/**
* @var string
*/
protected string $originalValue;

/**
* @var string[]|null
*/
protected ?array $allowedTags;

/**
* @param string $originalValue
Expand All @@ -20,6 +43,9 @@ public function __construct(string $originalValue, ?array $allowedTags = null)
$this->allowedTags = $allowedTags;
}

/**
* @return string
*/
public function __toString(): string
{
return (string) Mage::helper('core')->escapeHtml(
Expand All @@ -28,6 +54,9 @@ public function __toString(): string
);
}

/**
* @return string
*/
public function getUnescapedValue(): string
{
return $this->originalValue;
Expand Down
16 changes: 4 additions & 12 deletions app/code/core/Mage/Page/Block/Html/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public function setLogo($logo_src, $logo_alt)
public function getLogoSrc()
{
if (empty($this->_data['logo_src'])) {
$this->_data['logo_src'] = new Mage_Core_Model_Security_HtmlEscapedString(
(string) Mage::getStoreConfig('design/header/logo_src')
);
$this->_data['logo_src'] = $this->escapeHtml((string) Mage::getStoreConfig('design/header/logo_src'));
}
return $this->getSkinUrl($this->_data['logo_src']);
}
Expand All @@ -70,9 +68,7 @@ public function getLogoSrc()
public function getLogoSrcSmall()
{
if (empty($this->_data['logo_src_small'])) {
$this->_data['logo_src_small'] = new Mage_Core_Model_Security_HtmlEscapedString(
(string) Mage::getStoreConfig('design/header/logo_src_small')
);
$this->_data['logo_src_small'] = $this->escapeHtml((string) Mage::getStoreConfig('design/header/logo_src_small'));
}
return $this->getSkinUrl($this->_data['logo_src_small']);
}
Expand All @@ -83,9 +79,7 @@ public function getLogoSrcSmall()
public function getLogoAlt()
{
if (empty($this->_data['logo_alt'])) {
$this->_data['logo_alt'] = new Mage_Core_Model_Security_HtmlEscapedString(
(string) Mage::getStoreConfig('design/header/logo_alt')
);
$this->_data['logo_alt'] = $this->escapeHtml((string) Mage::getStoreConfig('design/header/logo_alt'));
}
return $this->_data['logo_alt'];
}
Expand All @@ -103,9 +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'] = new Mage_Core_Model_Security_HtmlEscapedString(
(string) Mage::getStoreConfig('design/header/welcome')
);
$this->_data['welcome'] = $this->escapeHtml((string) Mage::getStoreConfig('design/header/welcome'));
}
}

Expand Down
4 changes: 1 addition & 3 deletions app/code/core/Mage/Page/Block/Html/Welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +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'] = new Mage_Core_Model_Security_HtmlEscapedString(
(string) Mage::getStoreConfig('design/header/welcome')
);
$this->_data['welcome'] = $this->escapeHtml((string) Mage::getStoreConfig('design/header/welcome'));
}
}

Expand Down

0 comments on commit ae5df65

Please sign in to comment.