Skip to content

Commit

Permalink
Fix html escaping on var page header
Browse files Browse the repository at this point in the history
  • Loading branch information
zk committed Sep 21, 2014
1 parent 8107f7f commit 016ca0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/clj/clojuredocs/pages/vars.clj
Expand Up @@ -20,8 +20,12 @@
search/clojure-lib)

(defn $arglist [name a]
[:li.arglist (str
"(" name (when-not (empty? a) " ") a ")")])
[:li.arglist
(str "("
(util/html-encode name)
(when-not (empty? a) " ")
a
")")])

(defn see-alsos-for [{:keys [ns name library-url]}]
(->> (mon/fetch :see-alsos
Expand Down Expand Up @@ -84,7 +88,7 @@
(defn $var-header [{:keys [ns name added arglists] :as v}]
[:div.row.var-header
[:div.col-sm-8
[:h1.var-name name]]
[:h1.var-name (util/html-encode name)]]
[:div.col-sm-4
[:div.var-meta
[:h4 [:a {:href (str "/" ns)} ns]]
Expand Down
7 changes: 7 additions & 0 deletions src/cljx/clojuredocs/util.cljx
Expand Up @@ -28,6 +28,13 @@
(when s
(java.net.URLEncoder/encode s)))

#+clj
(defn html-encode [s]
(when s
(-> s
(str/replace #"<" "&lt;")
(str/replace #">" "&gt;"))))

(defn cd-decode [s]
(when s
(cond
Expand Down

0 comments on commit 016ca0d

Please sign in to comment.