Skip to content

fix: render uploaded HTML documents - #8

Merged
onmax merged 2 commits into
mainfrom
fix/render-html-documents
Sep 3, 2026
Merged

onmax merged 2 commits into
mainfrom
fix/render-html-documents

Conversation

@onmax

@onmax onmax commented Sep 3, 2026

Copy link
Copy Markdown
Member

Routes immutable .html uploads through the document middleware so their permanent URLs render in browsers instead of downloading as application/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 test
  • pnpm typecheck
  • git diff --check
  • Verify the existing .html reproduction URL returns text/html on the PR preview

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T20:43:34.803919Z a16156e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +33 to +34
const text = await source.text()
return isHtml ? text : renderMarkdownDocument(text, event.url.pathname, typesetStyles)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread README.md Outdated
```

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

1 participant