Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(text): validate note ID before building include reference-link href
Elian Doranb5d33e84374b
diff --git a/apps/client/src/services/content_renderer_text.ts b/apps/client/src/services/content_renderer_text.tsindex 3b43b184c5..0429c22b7a 100644--- a/apps/client/src/services/content_renderer_text.ts+++ b/apps/client/src/services/content_renderer_text.ts@@ -126,7 +126,9 @@ async function renderIncludedNotes(contentEl: HTMLElement, seenNoteIds: Set<strifunction replaceIncludesWithReferenceLinks(contentEl: HTMLElement) {for (const includeNoteEl of contentEl.querySelectorAll("section.include-note")) {const noteId = includeNoteEl.getAttribute("data-note-id");- if (!noteId) continue;+ // Validate the ID against a note-ID allow-list before interpolating it into the href: it+ // comes from note HTML, and the reference-link pass later reinterprets that href.+ if (!noteId || !/^[a-zA-Z0-9_]+$/.test(noteId)) continue;const referenceLink = document.createElement("a");referenceLink.className = "reference-link";