title in fancytree needs to be escaped for HTML special characters

This commit is contained in:
azivner 2017-12-28 19:00:31 -05:00
parent 332fc16852
commit 6426157bb3
3 changed files with 8 additions and 2 deletions

View File

@ -186,13 +186,15 @@ const noteTree = (function() {
const noteTreeId = getNoteTreeId(parentNoteId, noteId); const noteTreeId = getNoteTreeId(parentNoteId, noteId);
const noteTree = notesTreeMap[noteTreeId]; const noteTree = notesTreeMap[noteTreeId];
const title = (noteTree.prefix ? (noteTree.prefix + " - ") : "") + noteIdToTitle[noteTree.note_id];
const node = { const node = {
note_id: noteTree.note_id, note_id: noteTree.note_id,
parent_note_id: noteTree.parent_note_id, parent_note_id: noteTree.parent_note_id,
note_tree_id: noteTree.note_tree_id, note_tree_id: noteTree.note_tree_id,
is_protected: noteTree.is_protected, is_protected: noteTree.is_protected,
prefix: noteTree.prefix, prefix: noteTree.prefix,
title: (noteTree.prefix ? (noteTree.prefix + " - ") : "") + noteIdToTitle[noteTree.note_id], title: escapeHtml(title),
extraClasses: getExtraClasses(noteTree), extraClasses: getExtraClasses(noteTree),
refKey: noteTree.note_id, refKey: noteTree.note_id,
expanded: noteTree.is_expanded expanded: noteTree.is_expanded

View File

@ -37,7 +37,7 @@ const treeUtils = (function() {
const title = (prefix ? (prefix + " - ") : "") + noteTitle; const title = (prefix ? (prefix + " - ") : "") + noteTitle;
node.setTitle(title); node.setTitle(escapeHtml(title));
} }
return { return {

View File

@ -94,3 +94,7 @@ function isTopLevelNode(node) {
function isRootNode(node) { function isRootNode(node) {
return node.key === "root_1"; return node.key === "root_1";
} }
function escapeHtml(str) {
return $('<div/>').text(str).html();
}