Validate the file type
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 6 Nov 2024 08:26:55 +0000 (09:26 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 6 Nov 2024 08:26:55 +0000 (09:26 +0100)
ts/WoltLabSuite/Core/Component/Image/Cropper.ts

index c0a5fc35a7a47aa3954d896ecb80bbfbd808a546..d77a980f319f849f1fe3752e2f6bbb6c99072675 100644 (file)
@@ -253,6 +253,18 @@ export async function cropImage(
   file: File,
   configuration: CropperConfiguration,
 ): Promise<File> {
+  switch (file.type) {
+    case "image/jpeg":
+    case "image/png":
+    case "image/webp":
+      // Potential candidate for a resize operation.
+      break;
+
+    default:
+      // Not an image or an unsupported file type.
+      return file;
+  }
+
   let imageCropper: ImageCropper;
   switch (configuration.type) {
     case "exact":