Browse Source

sanitizing added

master
Christian Mueller 12 years ago
parent
commit
1800397fcf
  1. 6
      resources/public/js/main.js
  2. 10
      src/NoteHub/views/pages.clj

6
resources/public/js/main.js

@ -51,8 +51,10 @@ function onLoad() {
if(window.innerHeight >= document.body.clientHeight) { if(window.innerHeight >= document.body.clientHeight) {
var links = $("links"); var links = $("links");
links.style.position = "fixed"; if(links) {
links.style.bottom = 0; links.style.position = "fixed";
links.style.bottom = 0;
}
} }
} }

10
src/NoteHub/views/pages.clj

@ -40,6 +40,11 @@
(if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))] (if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))]
[:body {:onload "onLoad()"} content])) [:body {:onload "onLoad()"} content]))
(defn sanitize
"Breakes all usages of <script> & <iframe>"
[input]
(sreplace input #"(</?(iframe|script).*?>|javascript:)" ""))
; Sets a custom message for each needed HTTP status. ; Sets a custom message for each needed HTTP status.
; The message to be assigned is extracted with a dynamically generated key ; The message to be assigned is extracted with a dynamically generated key
(doseq [code [400 403 404 500]] (doseq [code [400 403 404 500]]
@ -102,9 +107,10 @@
(defpage "/:year/:month/:day/:title" {:keys [year month day title] :as params} (defpage "/:year/:month/:day/:title" {:keys [year month day title] :as params}
(let [noteID (api/build-key [year month day] title)] (let [noteID (api/build-key [year month day] title)]
(when (storage/note-exists? noteID) (when (storage/note-exists? noteID)
(let [note (api/get-note noteID)] (let [note (api/get-note noteID)
sanitized-note (sanitize (:note note))]
(layout (:title note) (layout (:title note)
(md-node :article.bottom-space (:note note)) (md-node :article.bottom-space sanitized-note)
(let [urls {:short-url (api/url (storage/create-short-url noteID params)) (let [urls {:short-url (api/url (storage/create-short-url noteID params))
:notehub "/"} :notehub "/"}
links (map #(link-to links (map #(link-to

Loading…
Cancel
Save