mirror of
https://github.com/penpot/penpot.git
synced 2025-08-04 10:28:23 +02:00
🐛 Fix possible bug in domain whitelisting checking.
This commit is contained in:
parent
e5d4755619
commit
08dce3bcdc
4 changed files with 39 additions and 33 deletions
|
@ -137,29 +137,34 @@
|
|||
|
||||
|
||||
;; --- SPEC: email
|
||||
(def email-re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+")
|
||||
|
||||
(let [re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+"
|
||||
cfn (fn [v]
|
||||
(if (string? v)
|
||||
(if-let [matches (re-seq re v)]
|
||||
(first matches)
|
||||
(do ::s/invalid))
|
||||
::s/invalid))]
|
||||
(s/def ::email (s/conformer cfn str)))
|
||||
|
||||
(s/def ::email
|
||||
(s/conformer
|
||||
(fn [v]
|
||||
(if (string? v)
|
||||
(if-let [matches (re-seq email-re v)]
|
||||
(first matches)
|
||||
(do ::s/invalid))
|
||||
::s/invalid))
|
||||
str))
|
||||
|
||||
;; --- SPEC: set-of-str
|
||||
(letfn [(conformer [s]
|
||||
(cond
|
||||
(string? s) (into #{} (str/split s #"\s*,\s*"))
|
||||
(set? s) (if (every? string? s)
|
||||
s
|
||||
::s/invalid)
|
||||
:else ::s/invalid))
|
||||
|
||||
(unformer [s]
|
||||
(str/join "," s))]
|
||||
(s/def ::set-of-str (s/conformer conformer unformer)))
|
||||
(s/def ::set-of-str
|
||||
(s/conformer
|
||||
(fn [s]
|
||||
(let [xform (comp
|
||||
(filter string?)
|
||||
(remove str/empty?)
|
||||
(remove str/blank?))]
|
||||
(cond
|
||||
(string? s) (->> (str/split s #"\s*,\s*")
|
||||
(into #{} xform))
|
||||
(set? s) (into #{} xform s)
|
||||
:else ::s/invalid)))
|
||||
(fn [s]
|
||||
(str/join "," s))))
|
||||
|
||||
;; --- Macros
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue