Skip to content

Commit 97ac11f

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 120ecf6 commit 97ac11f

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
@@ -509,7 +509,7 @@ function objectHierarchy(top, obj, args = undefined) {
509509
item._vclass = cssValueNum;
510510
} else if (isStr(fld)) {
511511
simple = true;
512-
item._value = '&quot;' + fld.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;') + '&quot;';
512+
item._value = '"' + fld + '"';
513513
item._vclass = 'h_value_str';
514514
} else if (typeof fld === 'undefined') {
515515
simple = true;
@@ -1306,8 +1306,10 @@ class HierarchyPainter extends BasePainter {
13061306

13071307
if ('_value' in hitem) {
13081308
const d3p = d3line.append('p');
1309-
if ('_vclass' in hitem) d3p.attr('class', hitem._vclass);
1310-
if (!hitem._isopen) d3p.html(hitem._value);
1309+
if ('_vclass' in hitem)
1310+
d3p.attr('class', hitem._vclass);
1311+
if (!hitem._isopen)
1312+
d3p.text(hitem._value);
13111313
}
13121314

13131315
if (has_childs && (isroot || hitem._isopen)) {
@@ -3885,7 +3887,7 @@ class HierarchyPainter extends BasePainter {
38853887
const layout = main.select('.gui_layout');
38863888
if (!layout.empty()) {
38873889
['simple', 'vert2', 'vert3', 'vert231', 'horiz2', 'horiz32', 'flex', 'tabs',
3888-
'grid 2x2', 'grid 1x3', 'grid 2x3', 'grid 3x3', 'grid 4x4'].forEach(kind => layout.append('option').attr('value', kind).html(kind));
3890+
'grid 2x2', 'grid 1x3', 'grid 2x3', 'grid 3x3', 'grid 4x4'].forEach(kind => layout.append('option').attr('value', kind).text(kind));
38893891

38903892
layout.on('change', ev => {
38913893
const kind = ev.target.value || 'flex';
@@ -3925,7 +3927,7 @@ class HierarchyPainter extends BasePainter {
39253927
}
39263928
if (!found) {
39273929
const opt = document.createElement('option');
3928-
opt.innerHTML = opt.value = this.getLayout();
3930+
opt.innerText = opt.value = this.getLayout();
39293931
selects.appendChild(opt);
39303932
selects.selectedIndex = selects.options.length - 1;
39313933
}

0 commit comments

Comments
 (0)