]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/ImageRepo.php
Modernize third party services' logos
[bookstack] / app / Uploads / ImageRepo.php
index 11507856140a0a7c330991cb8c488a1167257170..694560a14ca752994a1a2508f43ddb6d2a5740dc 100644 (file)
@@ -16,6 +16,8 @@ class ImageRepo
     protected $restrictionService;
     protected $page;
 
+    protected static $supportedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
+
     /**
      * ImageRepo constructor.
      */
@@ -31,6 +33,16 @@ class ImageRepo
         $this->page = $page;
     }
 
+    /**
+     * Check if the given image extension is supported by BookStack.
+     * The extension must not be altered in this function. This check should provide a guarantee
+     * that the provided extension is safe to use for the image to be saved.
+     */
+    public function imageExtensionSupported(string $extension): bool
+    {
+        return in_array($extension, static::$supportedExtensions);
+    }
+
     /**
      * Get an image with the given id.
      */