Skip to content

Build your personal knowledge base with Trilium Notes

title in fancytree needs to be escaped for HTML special characters

azivner6426157bb347
diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js
index 169db866d5..57c93e1f90 100644
--- a/public/javascripts/note_tree.js
+++ b/public/javascripts/note_tree.js
@@ -186,13 +186,15 @@ const noteTree = (function() {
const noteTreeId = getNoteTreeId(parentNoteId, noteId);
const noteTree = notesTreeMap[noteTreeId];
+ const title = (noteTree.prefix ? (noteTree.prefix + " - ") : "") + noteIdToTitle[noteTree.note_id];
+
const node = {
note_id: noteTree.note_id,
parent_note_id: noteTree.parent_note_id,
note_tree_id: noteTree.note_tree_id,
is_protected: noteTree.is_protected,
prefix: noteTree.prefix,
- title: (noteTree.prefix ? (noteTree.prefix + " - ") : "") + noteIdToTitle[noteTree.note_id],
+ title: escapeHtml(title),
extraClasses: getExtraClasses(noteTree),
refKey: noteTree.note_id,
expanded: noteTree.is_expanded
diff --git a/public/javascripts/tree_utils.js b/public/javascripts/tree_utils.js
index 673eaf9fc3..1d9813e093 100644
--- a/public/javascripts/tree_utils.js
+++ b/public/javascripts/tree_utils.js
@@ -37,7 +37,7 @@ const treeUtils = (function() {
const title = (prefix ? (prefix + " - ") : "") + noteTitle;
- node.setTitle(title);
+ node.setTitle(escapeHtml(title));
}
return {
diff --git a/public/javascripts/utils.js b/public/javascripts/utils.js
index 1f67844adc..1b390d1303 100644
--- a/public/javascripts/utils.js
+++ b/public/javascripts/utils.js
@@ -93,4 +93,8 @@ function isTopLevelNode(node) {
function isRootNode(node) {
return node.key === "root_1";
+}
+
+function escapeHtml(str) {
+ return $('<div/>').text(str).html();
}
\ No newline at end of file