Skip to content

Commit c3e5da1

Browse files
committed
Fix - avoid html use in hierarchy painter
When display object members as value avoid use of innerHTML to set content. It is sufficient to use text here. Same for display of options
1 parent b9f3b3d commit c3e5da1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

modules/gui/HierarchyPainter.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ function objectHierarchy(top, obj, args = undefined) {
529529
item._vclass = 'h_value_num';
530530
} else if (isStr(fld)) {
531531
simple = true;
532-
item._value = '&quot;' + fld.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;') + '&quot;';
532+
item._value = '"' + fld + '"';
533533
item._vclass = 'h_value_str';
534534
} else if (typeof fld === 'undefined') {
535535
simple = true;
@@ -1295,8 +1295,10 @@ class HierarchyPainter extends BasePainter {
12951295

12961296
if ('_value' in hitem) {
12971297
const d3p = d3line.append('p');
1298-
if ('_vclass' in hitem) d3p.attr('class', hitem._vclass);
1299-
if (!hitem._isopen) d3p.html(hitem._value);
1298+
if ('_vclass' in hitem)
1299+
d3p.attr('class', hitem._vclass);
1300+
if (!hitem._isopen)
1301+
d3p.text(hitem._value);
13001302
}
13011303

13021304
if (has_childs && (isroot || hitem._isopen)) {
@@ -3848,7 +3850,7 @@ class HierarchyPainter extends BasePainter {
38483850
const layout = main.select('.gui_layout');
38493851
if (!layout.empty()) {
38503852
['simple', 'vert2', 'vert3', 'vert231', 'horiz2', 'horiz32', 'flex', 'tabs',
3851-
'grid 2x2', 'grid 1x3', 'grid 2x3', 'grid 3x3', 'grid 4x4'].forEach(kind => layout.append('option').attr('value', kind).html(kind));
3853+
'grid 2x2', 'grid 1x3', 'grid 2x3', 'grid 3x3', 'grid 4x4'].forEach(kind => layout.append('option').attr('value', kind).text(kind));
38523854

38533855
layout.on('change', ev => {
38543856
const kind = ev.target.value || 'flex';
@@ -3888,7 +3890,7 @@ class HierarchyPainter extends BasePainter {
38883890
}
38893891
if (!found) {
38903892
const opt = document.createElement('option');
3891-
opt.innerHTML = opt.value = this.getLayout();
3893+
opt.innerText = opt.value = this.getLayout();
38923894
selects.appendChild(opt);
38933895
selects.selectedIndex = selects.options.length - 1;
38943896
}

0 commit comments

Comments
 (0)