Repository navigation
fix: render uploaded HTML documents - #8
Conversation
HTML uploads fell back to application/octet-stream because byte detection does not classify text. Route .html documents through the document middleware and isolate them with a CSP sandbox.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90c5b431d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const text = await source.text() | ||
| return isHtml ? text : renderMarkdownDocument(text, event.url.pathname, typesetStyles) |
There was a problem hiding this comment.
Preserve the uploaded HTML encoding
When a .html upload uses a non-UTF-8 encoding, such as Windows-1252, Blob.text() always decodes it as UTF-8 and the response explicitly declares UTF-8, so characters are replaced or corrupted instead of being rendered unchanged. The upload endpoint validates UTF-8 only for Markdown, so HTML with other encodings is currently accepted; preserve the original bytes and charset or reject HTML that is not valid UTF-8.
Useful? React with 👍 / 👎.
| ``` | ||
|
|
||
| The test uploads an image and a Markdown plan, confirms the image is publicly accessible, checks the rendered document and raw source, and exercises code-image rendering. | ||
| The test uploads an image, Markdown, and HTML, confirms their public responses, checks document rendering and raw Markdown, and exercises code-image rendering. |
There was a problem hiding this comment.
Exercise HTML in the documented deployed smoke test
This now says pnpm test:e2e:deployed uploads and checks HTML, but the referenced script still uploads only the PNG and plan.md; there is no HTML request or assertion anywhere in that test. Consequently the newly introduced routing, content type, and sandbox CSP can regress while the documented smoke test passes, so add the claimed HTML coverage or correct this statement.
Useful? React with 👍 / 👎.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
vitehub-drop-preview | a16156e | Sep 03 2026, 08:42 PM |
Block scripts in uploaded HTML, reject invalid UTF-8 HTML uploads, and align the public documentation with the deployed smoke-test coverage.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a16156e50b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { renderMarkdownDocument } from "../utils/markdown-document" | ||
|
|
||
| const MARKDOWN_PATH = /^\/i\/([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.(?:md|markdown))$/i | ||
| const DOCUMENT_PATH = /^\/i\/([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.(md|markdown|html))$/i |
There was a problem hiding this comment.
Route .htm uploads through document handling
When a user uploads the conventional page.htm extension, files.post.ts skips the new HTML UTF-8 handling and this matcher does not intercept the resulting URL, so it retains the generic blob response instead of the advertised sandboxed HTML rendering. Include .htm in both extension checks, or describe the feature specifically as supporting only .html files.
Useful? React with 👍 / 👎.
Routes immutable
.htmluploads through the document middleware so their permanent URLs render in browsers instead of downloading asapplication/octet-stream. Uploaded scripts may run, but a CSP sandbox gives the page an opaque origin and blocks forms, popups, external scripts, and all network access except HTTPS images.The public Drop skill, README, and landing-page copy now describe both Markdown and HTML rendering.
Test plan
pnpm testpnpm typecheckgit diff --check.htmlreproduction URL returnstext/htmlon the PR preview