Permalink
Browse files

Check to make sure captcha id is valid before trying to generate the …

…image. If captcha doesn't exist, really return a 404.
  • Loading branch information...
1 parent b849394 commit 41fc0eeb5e5c7b96132096d0fc24bf463d1e234b @robg robg committed Jun 30, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 app/controllers/simple_captcha_controller.rb
@@ -4,14 +4,15 @@ class SimpleCaptchaController < ActionController::Metal
# GET /simple_captcha
def show
- unless params[:id].blank?
+ unless params[:id].blank? || SimpleCaptcha::Utils::simple_captcha_value(params[:id]).blank?
send_file(
generate_simple_captcha_image(params[:id]),
:type => 'image/jpeg',
:disposition => 'inline',
:filename => 'simple_captcha.jpg')
else
- self.response_body = [404, {"Content-Type" => "text/html"}, ["Not Found"]]
+ self.status = :not_found
+ self.response_body = 'Not Found'
end
end
end

0 comments on commit 41fc0ee

Please sign in to comment.