Commit 320f1f19fc2467eb2eced759d92f871eb1450d3b

Authored by Braulio Bhavamitra
Committed by Rodrigo Souto
1 parent 00863a6e

Don't crash with invalid parameters

For example http://cirandas.net/dtygel/blog?month=10&year=2011/wp-login.php
crashes on date parsing

Answering request as if no date arguments were passed.

Closes !419

Signed-off-by: Rodrigo Souto <rodrigo@colivre.coop.br>
Signed-off-by: Braulio Bhavamitra <braulio@eita.org.br>
app/controllers/public/content_viewer_controller.rb
... ... @@ -239,8 +239,12 @@ class ContentViewerController &lt; ApplicationController
239 239  
240 240 def get_posts(year = nil, month = nil)
241 241 if year && month
242   - filter_date = DateTime.parse("#{year}-#{month}-01")
243   - return @page.posts.by_range(filter_date..filter_date.at_end_of_month)
  242 + begin
  243 + filter_date = DateTime.parse("#{year}-#{month}-01")
  244 + return @page.posts.by_range(filter_date..filter_date.at_end_of_month)
  245 + rescue ArgumentError
  246 + return @page.posts
  247 + end
244 248 else
245 249 return @page.posts
246 250 end
... ...