fix(spreadsheet uploads): make file extension comparisons case-insensitive (#32696)

This commit is contained in:
Sam Firke
2025-03-17 13:31:11 -04:00
committed by GitHub
parent f1a222d356
commit 6a13ab8920
2 changed files with 9 additions and 3 deletions

View File

@@ -185,8 +185,11 @@ export const validateUploadFileExtension = (
return false;
}
const fileType = extensionMatch[1];
return allowedExtensions.includes(fileType);
const fileType = extensionMatch[1].toLowerCase();
const lowerCaseAllowedExtensions = allowedExtensions.map(ext =>
ext.toLowerCase(),
);
return lowerCaseAllowedExtensions.includes(fileType);
};
interface StyledSwitchContainerProps extends SwitchProps {

View File

@@ -1086,7 +1086,10 @@ class BaseUploadFilePostSchemaMixin(Schema):
def validate_file_extension(self, file: FileStorage) -> None:
allowed_extensions = current_app.config["ALLOWED_EXTENSIONS"]
file_suffix = Path(file.filename).suffix
if not file_suffix or file_suffix[1:] not in allowed_extensions:
if not file_suffix:
raise ValidationError([_("File extension is not allowed.")])
# Make case-insensitive comparison
if file_suffix[1:].lower() not in [ext.lower() for ext in allowed_extensions]:
raise ValidationError([_("File extension is not allowed.")])