0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-10 00:58:26 -05:00

🐛 Fix unexpected exception on uploading invalid svg file.

This commit is contained in:
Andrey Antukh 2021-02-09 18:41:14 +01:00 committed by Andrés Moya
parent 946d40e6cd
commit 2b33300d79
2 changed files with 10 additions and 2 deletions

View file

@ -121,11 +121,16 @@
(defn parse
[data]
(with-open [istream (IOUtils/toInputStream data "UTF-8")]
(xml/parse istream)))
(try
(with-open [istream (IOUtils/toInputStream data "UTF-8")]
(xml/parse istream))
(catch org.xml.sax.SAXParseException _e
(ex/raise :type :validation
:code :invalid-svg-file))))
(defn process-request
[{:keys [svgc] :as cfg} body]
(let [data (slurp body)
data (svgc data)]
(parse data)))

View file

@ -421,6 +421,9 @@
(if (ex/ex-info? error)
(on-error* (ex-data error))
(cond
(= (:code error) :invalid-svg-file)
(rx/of (dm/error (tr "errors.media-type-not-allowed")))
(= (:code error) :media-type-not-allowed)
(rx/of (dm/error (tr "errors.media-type-not-allowed")))