Enhance text file detection logic for file attachments (#16199)

* feat: Enhances text file detection logic

* chore: Build static `webui` output

* chore: update webui build output
This commit is contained in:
Aleksander Grygier
2025-09-26 19:25:29 +02:00
committed by GitHub
parent 1a18927894
commit 807e8c6d31
5 changed files with 56 additions and 14 deletions

View File

@@ -0,0 +1,14 @@
export interface BinaryDetectionOptions {
/** Number of characters to check from the beginning of the file */
prefixLength: number;
/** Maximum ratio of suspicious characters allowed (0.0 to 1.0) */
suspiciousCharThresholdRatio: number;
/** Maximum absolute number of null bytes allowed */
maxAbsoluteNullBytes: number;
}
export const DEFAULT_BINARY_DETECTION_OPTIONS: BinaryDetectionOptions = {
prefixLength: 1024 * 10, // Check the first 10KB of the string
suspiciousCharThresholdRatio: 0.15, // Allow up to 15% suspicious chars
maxAbsoluteNullBytes: 2
};

View File

@@ -176,5 +176,13 @@ export const TEXT_FILE_TYPES = {
[FileTypeText.SVELTE]: {
extensions: [FileExtensionText.SVELTE],
mimeTypes: [MimeTypeText.SVELTE]
},
[FileTypeText.LATEX]: {
extensions: [FileExtensionText.TEX],
mimeTypes: [MimeTypeText.LATEX]
},
[FileTypeText.BIBTEX]: {
extensions: [FileExtensionText.BIB],
mimeTypes: [MimeTypeText.BIBTEX]
}
} as const;