WIP: form attachments — unit tests, test e-mail with attachment, lint
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
02b1e96d3d
commit
701bb420c1
@@ -2,7 +2,7 @@ import type { FileFieldConfig, ResolvedFormAttachments } from './config.js'
|
||||
|
||||
import { fileFieldLimits } from './config.js'
|
||||
import { checkFileContent, looksExecutable, matchFileType, SIGNATURE_BYTES, signatureMatches } from './fileChecks.js'
|
||||
import { describeFileTypes, MB, safeFileName } from './fileTypes.js'
|
||||
import { describeFileTypes, MB, safeFileName, UNSAFE_NAME_CHARACTERS } from './fileTypes.js'
|
||||
|
||||
/** A file that passed every check — in memory, ready for the e-mail. */
|
||||
export type AcceptedFormFile = {
|
||||
@@ -41,8 +41,7 @@ export type FileSlot = {
|
||||
tooLarge: () => FormFileFailure
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-control-regex
|
||||
const displayName = (name: string) => (name.split(/[/\\]/).pop() ?? '').replace(/[\u0000-\u001F\u007F--]/g, '').slice(0, 120)
|
||||
const displayName = (name: string) => (name.split(/[/\\]/).pop() ?? '').replace(UNSAFE_NAME_CHARACTERS, '').slice(0, 120)
|
||||
|
||||
/** A limit in MB for a message: whole number, or one decimal rounded DOWN (never promise more). */
|
||||
export const limitInMB = (bytes: number) => {
|
||||
|
||||
Reference in New Issue
Block a user