mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
Merge pull request #653: test(uploads): pin the browser's copies of the document list to ALLOWED_DOCUMENT_EXTS
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> # Conflicts: # CLAUDE.md
This commit is contained in:
commit
7edea53841
3 files changed
+170
-7
No files matched your search
@@ -330,6 +330,23 @@ export function stripInkRedrawBloat(buffer: string): string {
|
||||
*/
|
||||
const TEXT_UPLOAD_EXTS = new Set(['.txt', '.md', '.csv', '.tsv', '.json', '.log', '.yaml', '.yml', '.xml']);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* imageMagicMatchesExt (signature, or UTF-8 without NUL for text). The browser
|
||||
* keeps its own copies (test/upload-document-list-parity.test.ts pins them).
|
||||
*/
|
||||
export const ALLOWED_DOCUMENT_EXTS: ReadonlySet<string> = new Set([
|
||||
'.pdf',
|
||||
'.docx',
|
||||
'.pptx',
|
||||
'.xlsx',
|
||||
'.zip',
|
||||
...TEXT_UPLOAD_EXTS,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Validate upload bytes against a declared extension. Sniffs the first ~12 bytes
|
||||
* for a known magic-number signature (a text file is instead required to be
|
||||
@@ -5447,12 +5464,6 @@ export function registerSessionRoutes(
|
||||
// so an uploaded video is a type that previews. 3gp/mkv are deliberately out: they
|
||||
// would upload but not preview, and a phone's camera roll produces neither.
|
||||
const ALLOWED_VIDEO_EXTS = new Set([...VIDEO_ATTACHMENT_EXTENSIONS].map((e) => `.${e}`));
|
||||
// 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
|
||||
// imageMagicMatchesExt (signature, or UTF-8 without NUL for text).
|
||||
const ALLOWED_DOCUMENT_EXTS = new Set(['.pdf', '.docx', '.pptx', '.xlsx', '.zip', ...TEXT_UPLOAD_EXTS]);
|
||||
const VIDEO_MIME_EXT: Record<string, string> = {
|
||||
mp4: '.mp4',
|
||||
quicktime: '.mov',
|
||||
|
||||
Reference in new issue
Block a user