diff options
| author | sostler <sbostler@gmail.com> | 2010-01-30 02:36:04 -0500 |
|---|---|---|
| committer | sostler <sbostler@gmail.com> | 2010-01-30 02:36:04 -0500 |
| commit | 5084703f4d0ddb1312cca136d03900e5ef119bb6 (patch) | |
| tree | 036d89c708e471e73e6c3cbef656b51816def70e /src | |
| parent | 1dcfbf2578d41c5442c21f3f58170049bb2e6f1a (diff) | |
Use compojure escape-html function
Diffstat (limited to 'src')
| -rwxr-xr-x | src/site.clj | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/site.clj b/src/site.clj index c0a6ab4..e7d401f 100755 --- a/src/site.clj +++ b/src/site.clj @@ -66,22 +66,6 @@ ;; Utils -(defn replace-in-str [s table] - (loop [ret s - [[char replacement] & rest] table] - (if (nil? char) - ret - (recur (.replaceAll ret char replacement) - rest)))) - -(defn encode-html-entities [s] - (replace-in-str s [["&" "&"] - ["'" "'"] - ["\"" """] - ["<" "<"] - [">" ">"]])) - - (defn swap [f] (fn [& more] (apply f (reverse more)))) @@ -148,10 +132,10 @@ (assoc d :created_on (.getTime (d :created_on)))) (defn process-message-for-output [d] - {"nick" (encode-html-entities (d :nick)) + {"nick" (escape-html (d :nick)) "message_id" (d :message_id) "created_on" (.format formatter (d :created_on)) - "content" (encode-html-entities (d :content))}) + "content" (escape-html (d :content))}) (defn new-messages [room since-ts] (let [since-date (new Date (long since-ts))] @@ -161,7 +145,7 @@ (defn process-user [u] (if (non-empty-string? (u :avatar)) {"nick" (u :nick) - "avatar" (encode-html-entities (u :avatar))} + "avatar" (escape-html (u :avatar))} {"nick" (u :nick)})) (defn prepare-user-list [room] @@ -289,7 +273,7 @@ (doseq [a [:nick :avatar :contact :bio]] (let [v (user-info a)] (.setAttribute st (name a) - (if (non-empty-string? v) (encode-html-entities v))))) + (if (non-empty-string? v) (escape-html v))))) (.setAttribute st "dumps" (to-array (map process-message-for-output dumps))) (if (< (+ dump-offset dumps-per-page) dump-count) |
