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:
committed by
GitHub
parent
1a18927894
commit
807e8c6d31
14
tools/server/webui/src/lib/constants/binary-detection.ts
Normal file
14
tools/server/webui/src/lib/constants/binary-detection.ts
Normal 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
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user