Skip to content

feat(uploads): prompt uploads accept .html and .htm as documents - #869

Merged
Ark0N merged 2 commits into
Ark0N:masterfrom
ludovicfourrage:feat/upload-html-documents
Dec 3, 2026
Merged

Ark0N merged 2 commits into
Ark0N:masterfrom
ludovicfourrage:feat/upload-html-documents

Conversation

@ludovicfourrage

@ludovicfourrage ludovicfourrage commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #868.

Prompt uploads accept .html and .htm as documents. AI tools write specifications, reports and plans as HTML as often as Markdown, and handing one to a session as context is the same job as attaching a .md. Until now paste, drop and every Attach picker refused them with "Unsupported file type".

What changes:

  • TEXT_UPLOAD_EXTS in session-routes.ts gains .html and .htm, so they join ALLOWED_DOCUMENT_EXTS and are judged like the rest of the text family: valid UTF-8 with no NUL byte, saved to .codeman-uploads/ under a cleaned-up copy of their name.
  • The browser copies the parity test pins follow: _promptAttachKind in image-input.js, the accept= of #attachFileInput in index.html, and both .paste-file-input pickers in keyboard-accessory.js. The file-path link patterns already link html?.
  • The comments, CLAUDE.md, docs/api-reference.md and the Working With Files wiki page now say why HTML is in and scripts are still out.
  • A patch changeset is included.

Why this stores nothing Codeman would serve or run. This revisits the call on #553, where html, htm and svg were named as types to keep out of uploads; no code change prompted it. The two protections that keep an uploaded page inert predate the document list (the sandboxed html-view and its hidden-directory rule shipped in 1.41.1, #547), and both are now pinned for uploads by tests:

  • file-raw has no html entry in its MIME table, so an uploaded page goes out as application/octet-stream with nosniff, which a browser downloads rather than renders. New test in test/routes/file-routes.test.ts, for .html and .htm under .codeman-uploads/.
  • html-view refuses a page in a hidden directory. The existing test now also names .codeman-uploads (test/routes/html-view-routes.test.ts).

An .html sent with an image MIME type still takes the image path and fails its magic-byte check, as before.

Validation:

  • Updated tests: the document upload test accepts spec.html (text/html) and report.HTM (no usable MIME); the refusal test keeps .sh and .py and adds .js; the classifier test expects document for both extensions; the picker accept= fixtures list them.
  • With the source change reverted, the three accept tests fail (server upload, browser classifier, Compose picker); with it, they pass. The two safety tests pass either way, because they pin what upstream already does.
  • upload-document-list-parity, session-routes, file-routes, html-view-routes, mobile-prompt-composer and toolbar-attach: 330 of 333 pass locally. The 3 that fail are in toolbar-attach.test.ts and fail the same way on unmodified master in my environment (SecurityError: localStorage is not available for opaque origins, from a different jsdom version than the repo's). One of them is the drop test I edited, so CI is its first real run.
  • What I did not run. I didn't run the full npm test or tsc locally: this checkout used existing packages rather than an install. The changed TypeScript passes Prettier with the repo's config, and the two public JS files pass node --check. The PR's CI runs the full suite, typecheck, lint and the boot smoke test.

🤖 Generated with Claude Code

AI tools write specifications, reports and plans as HTML as often as
Markdown, and handing one to a session as context is the same job as
attaching a .md. Paste, drop and every Attach picker refused them with
"Unsupported file type".

.html/.htm join the text family (UTF-8, no NUL byte) on the server and in
every browser copy the parity test pins. An upload is stored to be read,
never rendered on Codeman's origin: file-raw serves it as octet-stream with
nosniff and html-view refuses a page under .codeman-uploads, both now pinned
by tests. Scripts (.sh, .py, .js) are still refused.

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

Ark0N commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Thanks @ludovicfourrage. This PR lets paste, drop and every Attach picker take .html and .htm as documents. They are checked like the rest of the text family and saved in .codeman-uploads/.

The code change is clean. The server list, _promptAttachKind, the three accept= lists and the parity test all agree. The two new safety tests pin that file-raw serves an uploaded page as application/octet-stream with nosniff, and that html-view refuses one under .codeman-uploads. The three toolbar-attach tests that failed in your environment pass here, and so do typecheck, lint, format and the full npm test.

Three places in the docs still describe the old refusal:

  1. docs/api-reference.md:901-906: the list two lines above now includes .html, .htm, but this paragraph still says "(a script, an HTML page, a .sh) is refused 400" and ends with "html and svg are the ones deliberately kept out". Please limit the example to scripts (.sh, .py, .js). The last clause should say that html/htm are admitted and stay inert (octet-stream + nosniff from file-raw, and html-view refuses dot-directories), which leaves svg as the markup type still kept out.
  2. docs/architecture-invariants.md:1402 (the Image upload part of that line): the text family there still ends at xml, and the line still says "sh/py/js/html are a deliberate SCOPE exclusion". Please make the same edit you made to the Prompt uploads paragraph in CLAUDE.md.
  3. docs/wiki/Working-With-Files.md:264: "(opening it downloads it)" is not what the user sees. Clicking the uploaded path opens the File Viewer, and for a page in a hidden folder it falls back to the source view (the same page says so a little higher up). Something like "(the File Viewer shows its source; Codeman never renders it as a page)" is accurate.

If you push those three edits, this is ready to merge. If not, they can be applied at merge time.

api-reference limits the refused example to scripts and says html/htm are
admitted and inert, leaving svg as the markup type kept out.
architecture-invariants lists html/htm in the text family and drops html from
the scope exclusion, as CLAUDE.md does. The wiki says the File Viewer shows an
uploaded page's source, which is what a click on its path does.

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

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed 5374d02 with the three doc edits:

  1. docs/api-reference.md: the refused example is limited to scripts (.sh, .py, .js), and the closing clause says .html/.htm are admitted and stay inert (octet-stream + nosniff from file-raw, html-view refuses dot-directories), which leaves svg as the markup type still kept out.
  2. docs/architecture-invariants.md: the Image upload text family now ends at html/htm, and the scope exclusion reads like the Prompt uploads paragraph in CLAUDE.md.
  3. docs/wiki/Working-With-Files.md: "(the File Viewer shows its source; Codeman never renders it as a page)".

I searched the rest of the repo for the old wording and found no other place.

Thanks also for the correction on #868: both protections predate the list, so this PR revisits the #553 call rather than following a code change. I've reworded the PR description to say so. The case for revisiting it is how these files are used. AI tools write specifications, reports and plans as Markdown or as HTML, and a user hands one to a session as context the same way as a .md. Today that means renaming it to .txt first, which stores the same bytes with no more protection than the .html would have. The risk you name, a rendered page reading the other uploads in its folder, rests on the hidden-directory rule, and the .codeman-uploads case added to html-view-routes.test.ts pins it.

@Ark0N

Ark0N commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Thanks for the quick follow-up, @ludovicfourrage. This PR lets paste, drop and every Attach picker take .html and .htm as documents, checked like the rest of the text family and saved in .codeman-uploads/.

All three doc edits from the last round are in. docs/api-reference.md limits the refused example to scripts and says why html/htm stay inert, docs/architecture-invariants.md matches the Prompt uploads paragraph in CLAUDE.md, and the wiki line now describes the File Viewer's source view. Typecheck, lint, format, the frontend syntax check and the full test suite pass, and CI is green. With the source change reverted, the three accept tests fail and the two safety tests still pass, as your description says.

One wording fix goes in at merge time. CLAUDE.md:242 now reads "keeping the server from storing what it would run", which says the server runs uploads. It should say "what an agent could run", the phrase docs/api-reference.md and docs/architecture-invariants.md already use.

This is ready to merge.

@Ark0N
Ark0N merged commit 7df0f11 into Ark0N:master Dec 3, 2026
2 checks passed
Ark0N pushed a commit that referenced this pull request Dec 3, 2026
The Prompt uploads paragraph said the server keeps out what it "would
run"; the scope exclusion keeps out what an agent could run, the phrase
docs/api-reference.md and docs/architecture-invariants.md already use.

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

Ark0N commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Merged, and shipped in Codeman 1.52.1. This closes #868.

One wording fix went on top, as the review said: the Prompt uploads paragraph in CLAUDE.md now says the scope exclusion keeps out "what an agent could run", the phrase docs/api-reference.md and docs/architecture-invariants.md already use. The release notes describe the change as you framed it: an HTML spec or report is attached like a .md, stored to be read and never rendered on Codeman's own origin.

Thanks for making the case for revisiting the old call, and for pinning both protections with tests.

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.

Pasting or attaching an .html file is refused as "Unsupported file type", though AI tools write specs and reports as HTML as often as Markdown

2 participants