From b565e20f1af28e5ea6807808624b5bdd9734a621 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 7 Jul 2023 12:45:10 +0200 Subject: [PATCH] :bug: Fix problem with slashes in layers names for exporter --- CHANGES.md | 1 + exporter/src/app/handlers/export_shapes.cljs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 47a996b10..af53fe712 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -52,6 +52,7 @@ - Fix picking a gradient color in recent colors for a new color in the assets tab [Taiga #5601](https://tree.taiga.io/project/penpot/issue/5601) - Fix problem with importation process [Taiga #5597](https://tree.taiga.io/project/penpot/issue/5597) - Fix problem with HSV color picker [#3317](https://github.com/penpot/penpot/issues/3317) +- Fix problem with slashes in layers names for exporter [#3276](https://github.com/penpot/penpot/issues/3276) ### :arrow_up: Deps updates diff --git a/exporter/src/app/handlers/export_shapes.cljs b/exporter/src/app/handlers/export_shapes.cljs index a8e108ae4..580a27460 100644 --- a/exporter/src/app/handlers/export_shapes.cljs +++ b/exporter/src/app/handlers/export_shapes.cljs @@ -23,6 +23,9 @@ (declare ^:private assoc-file-name) (declare prepare-exports) +;; Regex to clean namefiles +(def sanitize-file-regex #"[\\/:*?\"<>|]") + (s/def ::file-id ::us/uuid) (s/def ::filename ::us/string) (s/def ::name ::us/string) @@ -134,7 +137,7 @@ :on-progress on-progress) append (fn [{:keys [filename path] :as object}] - (rsc/add-to-zip! zip path filename)) + (rsc/add-to-zip! zip path (str/replace filename sanitize-file-regex "_"))) proc (-> (p/do (p/loop [exports (seq exports)] @@ -144,9 +147,7 @@ (p/recur (rest exports))))) (.finalize zip)) (p/then (constantly resource)) - (p/catch on-error)) - ] - + (p/catch on-error))] (if wait (p/then proc #(assoc exchange :response/body (dissoc % :path))) (assoc exchange :response/body (dissoc resource :path)))))