Skip to content

Make HTML in node titles optional #171

@Blinnikov

Description

@Blinnikov

Please consider using of innerText for <span> tag when constructing node's title to prevent HTML injection. For now if I have title of my node looking something like this: <hi>
then I will not see this title in the browser. It will be interpreted as html-tag.

The possible solution is to change line 2804

nodeTitle = "<span " + role + " class='fancytree-title'" + id + tooltip + tabindex + ">" + node.title + "</span>";

to something like this:

var span = document.createElement('span');
span.className = 'fancytree-title';
if (aria) {
    span.setAttribute('role', 'treeitem');
    span.setAttribute('id', 'ftal_' + node.key);
}
if (node.tooltip) {
    span.setAttribute('title', node.tooltip.replace(/\"/g, "&quot;"));
}
span.innerText = node.title;
nodeTitle = span.outerHTML;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions