From 00ea74de4dc575dbaf86f4a2b8dc11a3bcc0a63d Mon Sep 17 00:00:00 2001 From: TP Date: Thu, 7 Aug 2025 21:38:04 -0700 Subject: [PATCH] refactor: reuse escaped attachment filename --- sidepanel.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sidepanel.js b/sidepanel.js index b163621..4fd3717 100644 --- a/sidepanel.js +++ b/sidepanel.js @@ -1422,18 +1422,17 @@ class SideLlamaChat { previewDiv.dataset.attachmentId = attachment.id; let content = ''; + const safeFilename = this.escapeHtml(attachment.filename); if (attachment.type.startsWith('image/')) { // Validate that dataUrl is safe (must be data: URL for images) const safeDataUrl = this.sanitizeDataUrl(attachment.dataUrl); - const safeFilename = this.escapeHtml(attachment.filename); content = `${safeFilename}`; } else if (attachment.isTextFile && attachment.content) { // Show text content preview - const previewText = attachment.content.length > 100 - ? attachment.content.substring(0, 100) + '...' + const previewText = attachment.content.length > 100 + ? attachment.content.substring(0, 100) + '...' : attachment.content; const icon = this.getFileIcon(attachment.type, attachment.filename); - const safeFilename = this.escapeHtml(attachment.filename); content = `
@@ -1446,7 +1445,6 @@ class SideLlamaChat { } else { // File icon for other files const icon = this.getFileIcon(attachment.type, attachment.filename); - const safeFilename = this.escapeHtml(attachment.filename); content = `
${icon}
${safeFilename}
`; }