From 492e57d84531ec53b4ff23075bc883512dcff82e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 12 Oct 2016 19:21:38 +0200 Subject: [PATCH] Only allow upload a limited set of image types. --- src/uxbox/main/data/images.cljs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/uxbox/main/data/images.cljs b/src/uxbox/main/data/images.cljs index f8e209f1c..3acc9499a 100644 --- a/src/uxbox/main/data/images.cljs +++ b/src/uxbox/main/data/images.cljs @@ -191,12 +191,16 @@ ;; --- Create Image +(def allowed-file-types #{"image/jpeg" "image/png"}) + (defrecord CreateImages [coll-id files] rs/WatchEvent (-apply-watch [_ state s] (letfn [(image-size [file] (->> (files/get-image-size file) (rx/map (partial vector file)))) + (allowed-file? [file] + (contains? allowed-file-types (.-type file))) (prepare [[file [width height]]] {:coll coll-id :id (uuid/random) @@ -204,6 +208,7 @@ :width width :height height})] (->> (rx/from-coll (jscoll->vec files)) + (rx/filter allowed-file?) (rx/flat-map image-size) (rx/map prepare) (rx/flat-map #(rp/req :create/image %))