nathank
(Nathan Kershaw)
10 Giugno 2026, 3:14am
1
Sto notando che, quando è attiva l’anteprima PDF, cliccare sul link del PDF tenta di scaricarlo (comportamento indesiderato) invece di aprirlo in una nuova scheda.
Ciò avviene in un’installazione self-hosting semplice (singolo contenitore, senza CDN, senza S3).
Tutto questo è stato affrontato qui:
david:
Questo dovrebbe essere risolto da SECURITY: Download allowlist for uploaded files · discourse/discourse@9c0642a · GitHub
Ora disponiamo di una logica centralizzata per determinare quali file devono essere visualizzati «inline». Ciò significa che i PDF vengono visualizzati in modo coerente in linea, mentre alcuni tipi di file meno sicuri vengono sempre forniti come download. Queste modifiche dovrebbero funzionare su tutti i tipi di archiviazione dei file (locale e S3, con o senza CDN).
2 Mi Piace
C’era una mancanza di coerenza nel tipo display a seconda che si utilizzasse S3 o meno. Questo dovrebbe essere risolto da
main ← fix-inline-safe-uploads-local-store
approved 05:17PM - 14 Jul 26 UTC
Inline-safe uploads (images, PDFs, audio and video) served from the local
file s… tore were sent with `Content-Disposition: attachment`, so clicking a
PDF link downloaded the file instead of opening it in the browser. This was
inconsistent with the S3 store, which already serves these files inline, and
it left simple self-hosted (single-container, no S3/CDN) sites unable to open
PDFs inline.
`UploadsController#send_file_local_upload` only set the disposition to
`attachment` for unsafe types, and to `inline` when `?inline=1` was passed,
leaving it unset otherwise. Rails' `send_file` defaults an unset disposition
to `attachment`, so inline-safe files fell through to a download.
Inline-safe files are now served with `Content-Disposition: inline` by
default, mirroring the S3 store, while unsafe types (HTML, SVG, XML, ...) and
explicit downloads (`?dl=1`) keep the `attachment` disposition. The redundant
`params[:inline]` branch is removed, since inline-safe files are now inline by
default.
The `Content-Security-Policy: sandbox;` header stays on **every** response as
defense-in-depth: if the `is_inline_safe?` allowlist is ever wrong, the
sandbox forces an opaque origin and disables script execution so a
misclassified file cannot run as a document in our origin. It does not
interfere with inline viewing — `sandbox` sandboxes scripts *inside* the
served file, not the browser's native rendering of it. Chrome's built-in PDF
viewer and Firefox's pdf.js both render sandboxed PDFs identically to
unsandboxed ones, and images/audio/video decode natively regardless.
A spec locks the allowlist invariant by asserting no inline-safe extension
maps to a script-capable content type, so re-adding something like SVG or XML
to the allowlist fails CI instead of becoming a stored XSS.
(cc @david )
Il fatto che cliccando su un file si apra automaticamente in un’altra scheda è più una domanda di tipo product .
3 Mi Piace
david
(David Taylor)
Aperto
14 Luglio 2026, 5:14pm
5
La correzione non è ancora stata unita