|
| 1 | +diff --git a/vendor/magento/module-catalog/Helper/Category.php b/vendor/magento/module-catalog/Helper/Category.php |
| 2 | +index fe511d40e9caa..761dc6f62adda 100644 |
| 3 | +--- a/vendor/magento/module-catalog/Helper/Category.php |
| 4 | ++++ b/vendor/magento/module-catalog/Helper/Category.php |
| 5 | +@@ -10,8 +10,10 @@ |
| 6 | + use Magento\Catalog\Model\CategoryFactory; |
| 7 | + use Magento\Framework\App\Helper\AbstractHelper; |
| 8 | + use Magento\Framework\App\Helper\Context; |
| 9 | ++use Magento\Framework\App\ObjectManager; |
| 10 | + use Magento\Framework\Data\CollectionFactory; |
| 11 | + use Magento\Framework\Data\Tree\Node\Collection; |
| 12 | ++use Magento\Framework\Escaper; |
| 13 | + use Magento\Framework\Exception\NoSuchEntityException; |
| 14 | + use Magento\Framework\ObjectManager\ResetAfterRequestInterface; |
| 15 | + use Magento\Store\Model\ScopeInterface; |
| 16 | +@@ -63,24 +65,33 @@ class Category extends AbstractHelper implements ResetAfterRequestInterface |
| 17 | + */ |
| 18 | + protected $categoryRepository; |
| 19 | + |
| 20 | ++ /** |
| 21 | ++ * @var Escaper|null |
| 22 | ++ */ |
| 23 | ++ private ?Escaper $escaper; |
| 24 | ++ |
| 25 | + /** |
| 26 | + * @param Context $context |
| 27 | + * @param CategoryFactory $categoryFactory |
| 28 | + * @param StoreManagerInterface $storeManager |
| 29 | + * @param CollectionFactory $dataCollectionFactory |
| 30 | + * @param CategoryRepositoryInterface $categoryRepository |
| 31 | ++ * @param Escaper|null $escaper |
| 32 | + */ |
| 33 | + public function __construct( |
| 34 | + Context $context, |
| 35 | + CategoryFactory $categoryFactory, |
| 36 | + StoreManagerInterface $storeManager, |
| 37 | + CollectionFactory $dataCollectionFactory, |
| 38 | +- CategoryRepositoryInterface $categoryRepository |
| 39 | ++ CategoryRepositoryInterface $categoryRepository, |
| 40 | ++ ?Escaper $escaper = null |
| 41 | + ) { |
| 42 | + $this->_categoryFactory = $categoryFactory; |
| 43 | + $this->_storeManager = $storeManager; |
| 44 | + $this->_dataCollectionFactory = $dataCollectionFactory; |
| 45 | + $this->categoryRepository = $categoryRepository; |
| 46 | ++ $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class); |
| 47 | ++ |
| 48 | + parent::__construct($context); |
| 49 | + } |
| 50 | + |
| 51 | +@@ -204,6 +215,7 @@ public function getCanonicalUrl(string $categoryUrl): string |
| 52 | + if ($params && isset($params['p'])) { |
| 53 | + $categoryUrl = $categoryUrl . '?p=' . $params['p']; |
| 54 | + } |
| 55 | +- return $categoryUrl; |
| 56 | ++ |
| 57 | ++ return $this->escaper->escapeUrl($categoryUrl); |
| 58 | + } |
| 59 | + } |
0 commit comments