chore: replace re-find with safe-re-find

This commit is contained in:
Tienson Qin
2021-05-23 12:58:41 +08:00
parent d256982c9c
commit 6c70914150
17 changed files with 61 additions and 51 deletions

View File

@@ -1,5 +1,6 @@
(ns frontend.security
(:require [clojure.walk :as walk]))
(:require [clojure.walk :as walk]
[frontend.util :as util]))
;; To prevent from cross-site scripting vulnerability, we should add security checks for both hiccup and raw html.
;; Hiccup: [:a {:href "javascript:alert('hei')"} "click me"]
@@ -11,7 +12,7 @@
(= :a (first f))
(:href (second f))
(:href (second f))
(re-find #"(?i)javascript" (:href (second f)))))
(util/safe-re-find #"(?i)javascript" (:href (second f)))))
(defn remove-javascript-links-in-href
[hiccup]