fix: render PDF previews via <object> with blob: in object-src CSP #253

This commit is contained in:
Linus Rath
2026-05-06 00:54:46 +02:00
parent 9639a6bb75
commit e7be3d1e0c
2 changed files with 11 additions and 6 deletions
+10 -5
View File
@@ -221,12 +221,17 @@ export function FilePreviewModal({ name, onClose, onDownload, getFileContent }:
)}
{!loading && !error && fileType === "pdf" && objectUrl && (
<iframe
src={objectUrl}
sandbox="allow-scripts"
<object
data={objectUrl}
type="application/pdf"
className="w-full max-w-5xl h-full rounded-lg bg-white"
title={name}
/>
aria-label={name}
>
<Button onClick={() => void onDownload()}>
<Download className="w-4 h-4 mr-2" />
{t("download")}
</Button>
</object>
)}
{!loading && !error && fileType === "audio" && objectUrl && (
+1 -1
View File
@@ -43,7 +43,7 @@ export async function proxy(request: NextRequest) {
`font-src 'self'`,
`connect-src ${connectSrc}`,
frameSrc,
`object-src 'none'`,
`object-src 'self' blob:`,
`base-uri 'self'`,
`form-action 'self'`,
`frame-ancestors ${frameAncestors}`,