Preview promotion is a trust decision
A file extension and Content-Type can disagree with actual bytes. Serving unknown content from the same origin as your application can create additional browser risk. Define a limited set of accepted output formats and inspect them before attaching a trusted preview.
What to do next
- 01
Define expected types per task
Derive the allowed media family from the submitted operation and reviewed contract, then validate headers and bytes using an appropriate parser. Text JSON, raster images and MP4 video need different inspection paths.
- 02
Quarantine mismatches
Do not repair a suspicious object merely by changing its extension. Store restricted diagnostics or quarantine evidence under your local policy, and keep it away from normal inline rendering and automatic publication.
- 03
Serve verified content deliberately
Set the correct content type, appropriate disposition and no-sniff behavior at your own final response boundary. Test a synthetic HTML body labeled as an image to ensure it cannot become active content on the application origin.
A concrete example
Illustrative example: a fixture returns image/png but contains HTML text. The application rejects promotion to the image gallery and records a delivery-validation issue, preserving the original task reference for investigation.
Before you call it ready
- Expected types come from the operation.
- Mismatch bytes never reach trusted inline routes.
- Final response headers match verified content.
When to stop or choose another method
Stop fixing a type mismatch by renaming the file or trusting its extension without inspecting the representation you will serve.
