Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions sidepanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<img src="${safeDataUrl}" alt="${safeFilename}" title="${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 = `
<div class="text-file-preview" title="${safeFilename}">
<div class="file-header">
Expand All @@ -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 = `<div class="attachment-icon" title="${safeFilename}">${icon}<br><small>${safeFilename}</small></div>`;
}

Expand Down