mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix(spreadsheet uploads): make file extension comparisons case-insensitive (#32696)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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.")])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user