fix: render PDF previews via <object> with blob: in object-src CSP #253
This commit is contained in:
@@ -221,12 +221,17 @@ export function FilePreviewModal({ name, onClose, onDownload, getFileContent }:
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{!loading && !error && fileType === "pdf" && objectUrl && (
|
{!loading && !error && fileType === "pdf" && objectUrl && (
|
||||||
<iframe
|
<object
|
||||||
src={objectUrl}
|
data={objectUrl}
|
||||||
sandbox="allow-scripts"
|
type="application/pdf"
|
||||||
className="w-full max-w-5xl h-full rounded-lg bg-white"
|
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 && (
|
{!loading && !error && fileType === "audio" && objectUrl && (
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export async function proxy(request: NextRequest) {
|
|||||||
`font-src 'self'`,
|
`font-src 'self'`,
|
||||||
`connect-src ${connectSrc}`,
|
`connect-src ${connectSrc}`,
|
||||||
frameSrc,
|
frameSrc,
|
||||||
`object-src 'none'`,
|
`object-src 'self' blob:`,
|
||||||
`base-uri 'self'`,
|
`base-uri 'self'`,
|
||||||
`form-action 'self'`,
|
`form-action 'self'`,
|
||||||
`frame-ancestors ${frameAncestors}`,
|
`frame-ancestors ${frameAncestors}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user