diff --git a/client/src/components/TicketAttachments.tsx b/client/src/components/TicketAttachments.tsx index ce31022..e022983 100644 --- a/client/src/components/TicketAttachments.tsx +++ b/client/src/components/TicketAttachments.tsx @@ -114,6 +114,27 @@ export function TicketAttachments({ const isVideo = (type: string) => type.startsWith('video/'); const isPdf = (type: string) => type === 'application/pdf'; + const normalizedCdnHost = config?.cdnDomain + ? (() => { + const raw = config.cdnDomain.trim(); + try { + const parsed = new URL(raw.startsWith('http') ? raw : `https://${raw}`); + return parsed.hostname.toLowerCase(); + } catch { + return raw.replace(/^https?:\/\//i, '').split('/')[0].toLowerCase(); + } + })() + : null; + + const isTrustedCdnUrl = (url: string) => { + if (!normalizedCdnHost) return false; + try { + return new URL(url).hostname.toLowerCase() === normalizedCdnHost; + } catch { + return false; + } + }; + if (!config?.backblazeConfigured) { return (
@@ -200,19 +221,19 @@ export function TicketAttachments({ {attachment.fileName}
- {isImage(attachment.fileType) ? ( + {isImage(attachment.fileType) && isTrustedCdnUrl(attachment.url) ? ( {attachment.fileName} - ) : isVideo(attachment.fileType) ? ( + ) : isVideo(attachment.fileType) && isTrustedCdnUrl(attachment.url) ? (