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

This commit is contained in:
Codeman maintainer committed 2026-12-03 10:15:11 +01:00
commit 7df0f11892
14 files changed
+81 -25

No files matched your search

+1 -1
View File
@@ -306,7 +306,7 @@ Object.assign(CodemanApp.prototype, {
const ext = (file.name || '').toLowerCase().match(/\.([a-z0-9]+)$/)?.[1] || '';
if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'heic', 'heif'].includes(ext)) return 'image';
if (['mp4', 'webm', 'mov', 'm4v', 'ogv'].includes(ext)) return 'video';
if (['pdf', 'docx', 'pptx', 'xlsx', 'zip', 'txt', 'md', 'csv', 'tsv', 'json', 'log', 'yaml', 'yml', 'xml'].includes(ext)) {
if (['pdf', 'docx', 'pptx', 'xlsx', 'zip', 'txt', 'md', 'csv', 'tsv', 'json', 'log', 'yaml', 'yml', 'xml', 'html', 'htm'].includes(ext)) {
return 'document';
}
return null;
+1 -1
View File
@@ -870,7 +870,7 @@
<path d="m21 15-5-5L5 21"/>
</svg>
</button>
<input type="file" class="btn-attach-mobile-input" id="attachFileInput" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml" multiple tabindex="-1" aria-hidden="true">
<input type="file" class="btn-attach-mobile-input" id="attachFileInput" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml,.html,.htm" multiple tabindex="-1" aria-hidden="true">
</span>
<button class="btn-voice-mobile" id="voiceInputBtnMobile" onclick="VoiceInput.toggle()"
title="Voice input" aria-label="Start voice input" aria-pressed="false">
+2 -2
View File
@@ -1564,7 +1564,7 @@ const KeyboardAccessoryBar = {
<button type="button" class="paste-cancel">Cancel</button>
<button type="button" class="paste-send">Send</button>
</div>
<input type="file" class="paste-file-input" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml" multiple hidden>
<input type="file" class="paste-file-input" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml,.html,.htm" multiple hidden>
</div>
`;
@@ -1786,7 +1786,7 @@ const KeyboardAccessoryBar = {
<button class="paste-cancel">Cancel</button>
<button class="paste-send">Send</button>
</div>
<input type="file" class="paste-file-input" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml" multiple hidden>
<input type="file" class="paste-file-input" accept="image/*,video/*,.pdf,.docx,.pptx,.xlsx,.zip,.txt,.md,.csv,.tsv,.json,.log,.yaml,.yml,.xml,.html,.htm" multiple hidden>
</div>
`;
+22 -4
View File
@@ -437,14 +437,32 @@ export function stripInkRedrawBloat(buffer: string): string {
/**
* The text half of the document allowlist: these are judged on their encoding
* (valid UTF-8, no NUL byte) rather than on a signature, since plain text has none.
*
* HTML belongs here beside Markdown: AI tools write specifications, reports and
* plans as either, and handing one to a session as context is the same job as a
* .md. It is stored to be read, never rendered on Codeman's origin: file-raw
* serves .html/.htm as octet-stream with nosniff (a download), and html-view
* refuses a page in a hidden directory such as `.codeman-uploads`.
*/
const TEXT_UPLOAD_EXTS = new Set(['.txt', '.md', '.csv', '.tsv', '.json', '.log', '.yaml', '.yml', '.xml']);
const TEXT_UPLOAD_EXTS = new Set([
'.txt',
'.md',
'.csv',
'.tsv',
'.json',
'.log',
'.yaml',
'.yml',
'.xml',
'.html',
'.htm',
]);
/**
* Documents a user hands an agent to read: the office formats plus the text
* family. Curated on purpose, never SUPPORTED_ATTACHMENT_EXTENSIONS or
* EDITABLE_EXTENSIONS, which carry sh/py/js/html; a prompt upload is a thing
* to read, not a thing to run or serve. Each is judged on its bytes by
* EDITABLE_EXTENSIONS, which carry sh/py/js; a prompt upload is a thing
* to read, not a thing to run. Each is judged on its bytes by
* imageMagicMatchesExt (signature, or UTF-8 without NUL for text). The browser
* keeps its own copies (test/upload-document-list-parity.test.ts pins them).
*/
@@ -6378,7 +6396,7 @@ export function registerSessionRoutes(
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Could not convert HEIC image to JPEG');
}
} else if (!imageMagicMatchesExt(imageBytes, ext)) {
// A foreign extension with no image MIME (a script, an HTML page, a video
// A foreign extension with no image MIME (a script, a binary, a video
// without its flag) was never going to be an image: say so, rather than
// the ".png" the default extension would name. Decided only HERE, after
// the sniff, so anything the image path ever accepted by its bytes (a