mirror of
https://github.com/penpot/penpot.git
synced 2026-09-15 08:28:38 +00:00
🐛 Fix workspace crash when resolving thumbnail data URIs (#11563)
The workspace-thumbnail-by-id ref unconditionally called resolve-media on thumbnail URIs, which caused a stack overflow when the URI was a data URI (which can be megabytes long for large images). Data URIs contain thousands of '/' characters (base64 uses '/' as one of its 64 characters), causing lambdaisland.uri/join to iterate thousands of times in remove-dot-segments and overflow the JavaScript call stack. Add a resolved-uri? helper that checks if the URI already starts with 'blob:' or 'data:', and skip resolve-media for those cases. Only call resolve-media when the URI is a plain UUID (media-id from the server). Closes #11562 AI-assisted-by: qwen3.7-plus
This commit is contained in:
parent
8128e350c5
commit
5931f60d53
@ -19,6 +19,7 @@
|
||||
[app.main.store :as st]
|
||||
[app.main.streams :as ms]
|
||||
[beicon.v2.core :as rx]
|
||||
[clojure.string :as str]
|
||||
[okulary.core :as l]))
|
||||
|
||||
;; ---- Global refs
|
||||
@ -583,13 +584,21 @@
|
||||
(dm/get-in state [:viewer-local :zoom-type]))
|
||||
st/state))
|
||||
|
||||
(defn- resolved-uri?
|
||||
"Returns true if the uri is already a fully resolved URI (blob or data)."
|
||||
[uri]
|
||||
(or (str/starts-with? uri "blob:")
|
||||
(str/starts-with? uri "data:")))
|
||||
|
||||
(defn workspace-thumbnail-by-id
|
||||
[object-id]
|
||||
(l/derived
|
||||
(fn [state]
|
||||
(when-let [entry (dm/get-in state [:thumbnails object-id])]
|
||||
(cond-> entry
|
||||
(:uri entry) (update :uri cf/resolve-media))))
|
||||
(and (:uri entry)
|
||||
(not (resolved-uri? (:uri entry))))
|
||||
(update :uri cf/resolve-media))))
|
||||
st/state))
|
||||
|
||||
(def workspace-text-modifier
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user