Skip to content

Commit

Permalink
Parse project page numbers without reporting errors
Browse files Browse the repository at this point in the history
We get lots of garbage error reports from people fuzzing the page
parameter. This will return a specific error for them, and won't
report them to Yeller.

Relates to #492
  • Loading branch information
danielcompton committed Aug 22, 2016
1 parent 523c15b commit 5d5f4a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/clojars/web.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@
params)]
(search search-obj % validated-params))))
(GET "/projects" {:keys [params]}
(try-account
#(browse db % params)))
(try-account
#(let [validated-params (if (:page params)
(assoc params :page (try-parse-page (:page params)))
params)]
(browse db % validated-params))))
(GET "/security" []
(try-account
#(html-doc "Security" {:account %}
Expand Down
2 changes: 1 addition & 1 deletion src/clojars/web/browse.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
(let [i (count-projects-before db from)
page (inc (int (/ i per-page)))]
(redirect (str "/projects?page=" page "#" (mod i per-page))))
(browse-page db account (Integer. (or (:page params) 1)) per-page))))
(browse-page db account (or (:page params) 1) per-page))))

0 comments on commit 5d5f4a8

Please sign in to comment.