Fix desktop file uploads with extensions (#1741)
* fix(attachments): allow Markdown file uploads on desktop Desktop file upload copied picked files through managed storage with bare picker extensions like md. Normalize those extensions at the command boundary and pass dot-prefixed extensions from the picker path. * fix(attachments): stop enumerating generic file types Generic file uploads should not depend on a hand-maintained non-image MIME table. Keep raster image inference for image handling and use octet-stream for other path-only uploads. * test(attachments): cover picker extension format
This commit is contained in:
@@ -40,10 +40,11 @@ function normalizeExtension(value: unknown): string {
|
||||
throw new Error("Attachment extension must be a string.");
|
||||
}
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (!EXTENSION_PATTERN.test(normalized)) {
|
||||
const extension = normalized.startsWith(".") ? normalized : `.${normalized}`;
|
||||
if (!EXTENSION_PATTERN.test(extension)) {
|
||||
throw new Error(`Invalid attachment extension: ${value}`);
|
||||
}
|
||||
return normalized;
|
||||
return extension;
|
||||
}
|
||||
|
||||
async function buildManagedAttachmentPath(input: {
|
||||
|
||||
Reference in New Issue
Block a user