diff --git a/frontend/app.js b/frontend/app.js index 4820983..a2cf48d 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -1722,6 +1722,13 @@ function noteApp() { this.folderTree = tree; }, + // Helper to escape strings for use in inline JavaScript handlers + // Uses JSON.stringify for backslashes/control chars, plus single-quote escaping + // since our handlers use single-quoted strings: onclick="fn('${escaped}')" + escapeForInlineHandler(str) { + return JSON.stringify(str).slice(1, -1).replace(/'/g, "\\'"); + }, + // Render folder recursively (helper for deep nesting) renderFolderRecursive(folder, level = 0, isTopLevel = false) { if (!folder) return ''; @@ -1732,7 +1739,7 @@ function noteApp() { // Render this folder's header // Note: Using native event handlers (ondragstart, onclick, etc.) instead of Alpine directives // because x-html doesn't process Alpine directives in dynamically generated content - const escapedPath = folder.path.replace(/'/g, "\\'").replace(/\\/g, "\\\\"); + const escapedPath = this.escapeForInlineHandler(folder.path); html += `
+