Skip to content

fix: serve JSON and text downloads inline so they open in the browser - #2217

Open
MGpromax wants to merge 1 commit into
aboutcode-org:mainfrom
MGpromax:inline-json-downloads
Open

fix: serve JSON and text downloads inline so they open in the browser#2217
MGpromax wants to merge 1 commit into
aboutcode-org:mainfrom
MGpromax:inline-json-downloads

Conversation

@MGpromax

Copy link
Copy Markdown

Closes #2210

download_project_file() forced as_attachment=True for every input and output file, so a JSON output always became a separate download. This serves .json and .txt files inline instead -- FileResponse then also sets the proper content type from the filename (application/json / text/plain), so they open directly in the browser; all other formats keep forcing a download.

One deliberate scoping choice: .html (e.g. generated attribution documents) is not served inline, since those embed data derived from scanned third-party packages and rendering them in the app origin would be an XSS vector. Happy to extend the inline set if you prefer.

Tested with the existing download view tests plus a new one asserting Content-Type: application/json and Content-Disposition: inline for a JSON output (3/3 pass on sqlite locally).

download_project_file() forced every input and output file download
with as_attachment=True, so JSON results always downloaded as a
separate file instead of opening in the browser. Serve .json and
.txt files inline with their content type; other formats keep
forcing a download. HTML is deliberately not served inline since
generated attribution documents may embed third-party package data.

Closes aboutcode-org#2210

Signed-off-by: Manoj Gowda <manojgowdabs18@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open JSON output as JSON in the browser

1 participant