Skip to content

Download binaries served as text/html instead of rendering them - #875

Merged
rtibbles merged 1 commit into
learningequality:mainfrom
rtibblesbot:issue-867-db2ee0
Oct 22, 2026
Merged

rtibbles merged 1 commit into
learningequality:mainfrom
rtibblesbot:issue-867-db2ee0

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Binaries and SVGs served as text/html (e.g. img.php?id=3) are now downloaded under their sniffed extension instead of rendered.
  • Covers DownloadFile, HTMLZipFile, ContentNode(uri=...) and HTML5 archive refs.

References

Fixes #867.

Reviewer guidance

Suggested review: Full code review.

  • Accept the body heuristic: a filetype signature or a leading <svg/<!doctype svg now downloads instead of rendering, so a markup-free text page starting BM, ID3, OggS, MZ or %! is stored as .bmp/.mp3/.ogg/.exe/.ps.
  • Approve three side changes: containers at .php/.ashx-style URLs are named .zip even when labelled application/zip, the :script cache key re-downloads every cached script-extension URL once, and URLs an earlier run rendered keep that render until --update.
  • Confirm the request cost: an HTML page adds one GET of up to 8 KB on its first run, and an HTML-labelled binary pays HEAD plus two GETs on its first run and HEAD plus one GET on every later run.
  • Renders cached by an earlier run under the same URL are reused until the chef runs with --update.
  • A body that matches no signature still renders, so binary formats filetype cannot identify keep the old behaviour.

AI usage

Used Claude Code to plan, implement and test the change. Verified with the full test suite and prek.


Written by rtibblesbot, an LLM-based coding agent.

@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-10-20 05:10 UTC

@rtibblesbot
rtibblesbot marked this pull request as ready for review October 19, 2026 01:47
@rtibblesbot
rtibblesbot requested review from a team and leq-bot October 19, 2026 01:47
SingleFileRenderHandler sniffs the response body; a filetype or SVG
signature downloads the file under its sniffed extension.

Fixes learningequality#867

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rtibbles rtibbles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes make sense and fix the regression of behaviour for these files since 0.7.3

@rtibbles
rtibbles merged commit 13bc497 into learningequality:main Oct 22, 2026
19 checks passed
@rtibblesbot

Copy link
Copy Markdown
Contributor Author

Quick check on rtibblesbot's work on this PR: react 👍 helpful · 😕 mixed · 👎 not helpful. Reply with anything specific.

@rtibblesbot
rtibblesbot deleted the issue-867-db2ee0 branch October 22, 2026 22:33
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.

A PNG or zip served as text/html to a DownloadFile, HTMLZipFile, node uri or archive ref downloads instead of rendering

2 participants