Skip to content

Commit bd5834c

Browse files
committed
#13296: Category name with special characters brakes in url rewrites category tree
- Load Category Tree in url rewrite page when there is special characters
1 parent 535486f commit bd5834c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ define([
1010
], function ($) {
1111
'use strict';
1212

13+
var decodeEntities = (function () {
14+
//create a new html document (doesn't execute script tags in child elements)
15+
var doc = document.implementation.createHTMLDocument("");
16+
var element = doc.createElement('div');
17+
18+
function getText(str) {
19+
element.innerHTML = str;
20+
str = element.textContent;
21+
element.textContent = '';
22+
return str;
23+
}
24+
25+
function decodeHTMLEntities(str) {
26+
if (str && typeof str === 'string') {
27+
var x = getText(str);
28+
while (str !== x) {
29+
str = x;
30+
x = getText(x);
31+
}
32+
return x;
33+
}
34+
}
35+
return decodeHTMLEntities;
36+
})();
37+
1338
$.widget('mage.categoryTree', {
1439
options: {
1540
url: '',
@@ -90,7 +115,7 @@ define([
90115
}
91116
result = {
92117
data: {
93-
title: node.name + ' (' + node['product_count'] + ')'
118+
title: decodeEntities(node.name) + ' (' + node['product_count'] + ')'
94119
},
95120
attr: {
96121
'class': node.cls + (!!node.disabled ? ' disabled' : '') //eslint-disable-line no-extra-boolean-cast

app/code/Magento/UrlRewrite/Block/Catalog/Category/Tree.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected function _getNodesArray($node)
162162
'children_count' => (int)$node->getChildrenCount(),
163163
'is_active' => (bool)$node->getIsActive(),
164164
// Scrub names for raw js output
165-
'name' => $this->escapeHtml($node->getName()),
165+
'name' => htmlspecialchars($this->escapeHtml($node->getName()), ENT_COMPAT, 'UTF-8'),
166166
'level' => (int)$node->getLevel(),
167167
'product_count' => (int)$node->getProductCount(),
168168
];

0 commit comments

Comments
 (0)