Git Product home page Git Product logo

simple-captcha's People

Contributors

aliaksandrb avatar arthurmolina avatar azdaroth avatar bfbones avatar chipiga avatar cmrd-senya avatar coolnitz avatar denschub avatar fmbiete avatar freemanoid avatar friend-lga avatar galetahub avatar guilhermeguitte avatar igaiga avatar incubus avatar izzm avatar jedifreeman avatar kuldeepaggarwal avatar lionello avatar mrhead avatar nolamesa avatar philippneugebauer avatar praveenggg avatar rlisowski avatar rubyconvict avatar smaboshe avatar soylent avatar superp avatar vysogot avatar zealot128 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-captcha's Issues

Captchas not being generated in versions > 0.3.2.

Hi there,

After a recent upgrade I noticed that captchas were not showing up:

screen shot 2016-02-02 at 11 04 22

I didn't see any errors in my server log, but my guess is that the tempfile changes generate_simple_captcha_image might be the problem?

Versions:

  • simple_captcha2 0.3.4
  • rails 4.2.1.5
  • ruby 2.2.4p230
  • ImageMagick 6.8.9-9 Q16 x86_64
  • Debian GNU/Linux 8.2 (jessie)

Version 0.4.0 had the same problem. Changing the simple_captcha2 version to 0.3.2 "fixed" the issue.

irb(main):001:0> include SimpleCaptcha::ImageHelpers
=> Object
irb(main):002:0> generate_simple_captcha_image('asdf')
  SimpleCaptcha::SimpleCaptchaData Load (1.4ms)  SELECT  `simple_captcha_data`.* FROM `simple_captcha_data` WHERE `simple_captcha_data`.`key` = 'asdf'  ORDER BY `simple_captcha_data`.`id` ASC LIMIT 1
-background '#fff' -fill '#000' -size 100x28 -wave 1x86 -gravity Center -pointsize 22 -implode 0.2 label: -evaluate Uniform-noise 0 jpeg:-
StandardError: Error while running convert: convert: no images defined `jpeg:-' @ error/convert.c/ConvertImageCommand/3210.

    from /usr/local/lib/ruby/gems/2.2.0/gems/simple_captcha2-0.3.4/lib/simple_captcha/utils.rb:17:in `run'
    from /usr/local/lib/ruby/gems/2.2.0/gems/simple_captcha2-0.3.4/lib/simple_captcha/image.rb:83:in `generate_simple_captcha_image'
    from (irb):2
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:in `start'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in `start'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Readability of generated image

Our users had some issues with readability of generated images so I had to disable implode option for convert in simple captcha source code.

According to the doc distortion handles the complexity of the image. But it can be still bad (thanks to the implode) even if distortion is set to low.

I see to possible solutions and I will be happy to implement them:

  1. Add new implode option.
  2. Rename distortion to something like image_complexity which would handle both implode and distortion.

@pludoni what do you think about it? Would you accept such PR?

simple_captcha_valid? is self destructing or something?

First thanks for maintaining this great plugin, I am pretty new to RoR so i sadly i can't contribute with code/fix.

The problem is mostly in lib/simple_captcha/controller.rb if you use simple_captcha_valid? twice in the same controller it will always return false the second time it's used even if the user enters the right code.

I bypassed this by assigning a variable to simple_captcha_valid? and using that variable in validation.

Best regards

undefined method `implode=' for SimpleCaptcha:Module (NoMethodError)

config/initializers/simple_captcha.rb:27:in block in <top (required)>': undefined methodimplode=' for SimpleCaptcha:Module (NoMethodError)

simple_captcha.rb

SimpleCaptcha.setup do |sc|

default: 100x28

sc.image_size = '100x34'

default: 5

sc.length = 5

default: simply_blue

possible values:

'embosed_silver',

'simply_red',

'simply_green',

'simply_blue',

'distorted_black',

'all_black',

'charcoal_grey',

'almost_invisible'

'random'

sc.image_style = 'charcoal_grey'

default: low

possible values: 'low', 'medium', 'high', 'random'

sc.distortion = 'medium'

default: medium

possible values: 'none', 'low', 'medium', 'high'

sc.implode = 'low'
end

issue with unicorn server

I am using this gem with rails 4.1 and ruby 2.1.1

it works fine in unicorn with development mode but when I run unicorn server in production mode captcha image is not generated

following is logs from unicorn console
Started GET "/simple_captcha?code=0ba5959339d14bd28f770ea81519f42306ee517d&time=1399443832" for 127.0.0.1 at 2014-05-07 11:53:52 +0530
E, [2014-05-07T11:53:52.951287 #14092] ERROR -- : app error: closed stream (IOError)
E, [2014-05-07T11:53:52.951450 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in each' E, [2014-05-07T11:53:52.951508 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:ineach'
E, [2014-05-07T11:53:52.951563 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in each' E, [2014-05-07T11:53:52.951609 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:ineach'
E, [2014-05-07T11:53:52.951648 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in each' E, [2014-05-07T11:53:52.951691 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/lib/unicorn/http_response.rb:60:inhttp_response_write'
E, [2014-05-07T11:53:52.951742 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:582:in process_client' E, [2014-05-07T11:53:52.951783 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:666:inworker_loop'
E, [2014-05-07T11:53:52.951826 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:521:in spawn_missing_workers' E, [2014-05-07T11:53:52.951867 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:140:instart'
E, [2014-05-07T11:53:52.951909 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/gems/unicorn-4.8.2/bin/unicorn:126:in <top (required)>' E, [2014-05-07T11:53:52.951949 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/bin/unicorn:23:inload'
E, [2014-05-07T11:53:52.952007 #14092] ERROR -- : /home/loken/.rvm/gems/ruby-2.1.1@earnfx/bin/unicorn:23:in `

'

Can't mass-assign protected attributes: captcha, captcha_key

ruby 1.9.3, rails 3.2.19

Error

Can't mass-assign protected attributes: captcha, captcha_key

To fix this have added attr_accessible into User model.

attr_accessible :captcha, :captcha_key

And now its allowing me to register with wrong captcha as well

Field key doesn't have a default value

Hi,

We're seeing this error when trying to show a captcha with Rails 4.0.2:

"Mysql2::Error: Field 'key' doesn't have a default value: INSERT INTO simple_captcha_data (created_at, updated_at, value) VALUES (1388118456, 1388118456, 'VDFKK')"

We 'fixed' this by adding 'attr_accessible :key, :value' in lib/simple_captcha/simple_captcha_data.rb

404 when image URL is not loaded from rails page

I'm trying to integrate simple-captcha into a non-rails page, but even though I can get the captcha through a call to my rails API, the generated img "src" always assumes it will be used by the same rails app.

I need a way to force the generated img "src" to use the absolute URL.

This code in view.rb needs to change:

        url = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/simple_captcha?code=#{simple_captcha_key}&#{query}"

Also, that line is duplicated in that file and could be refactored.

Add a class to the text field

Hi im using simple-captcha2 with bootstrap, and of course im trying to match the style, but thats very difficult, even if there is a partial because i need to add classes to the input.

Could you make it possible to edit the object html in the simple_captcha_field method?

Captcha-generation with ImageMagick > 6.9.6 fails

ArchLinux @ 2016-11-14

ImageMagick with versions starting from 6.9.6 fail because no font is given;
Take for example an example-command generated by simple-captcha2:

convert -fill darkblue -background white -size 100x28 -wave 1x88 -gravity Center -pointsize 22 -implode 0.2 label:BXVXN jpeg:- 2>&1

The output will be

convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1312.
convert: no images defined `jpeg:-' @ error/convert.c/ConvertImageCommand/3257.

Specifying a font with -font MyFont in the command makes it work again.

See also ImageMagick/ImageMagick#300

What about publishing a new gem?

Official simple-captcha repo and all its forks (https://github.com/Azdaroth/simple-captcha https://github.com/ignacy/simple-captcha-mirror https://github.com/macarthy/simple-captcha-mirror https://github.com/galetahub/simple-captcha)
seems to not supported anymore.

It's not convenient to add the most modern version of simple captcha like this

gem 'simple-captcha', github: 'pludoni/simple-captcha'

So we can publish a new gem smthing like updated-simple-captcha or simple-captcha-on-steroids
Of course we had to keep all references to gem creators.

Gem breaks when middleware placed after mobvious in middleware stack

Using rails 4, this gem breaks when SimpleCaptcha::Middleware is placed after Mobvious::Manager of the mobvious gem in the middleware stack. I fixed the problem with the following lines in application.rb:

    config.middleware.delete "SimpleCaptcha::Middleware"
    config.middleware.insert_before(Mobvious::Manager, SimpleCaptcha::Middleware)

Potential XSS flaw

In middleware.rb, a request parameter is passed directly to the response body without being escaped.
id = request.params['id']

the parameter should be wrapped in html_escape to prevent possible XSS
id = html_escape(request.params['id'])

Please see this example URI as proof:
simple_captcha/?id=%22)%3B%20%3Cscript%20type=%27text/javascript%27%3Ealert(%27xss%27](url))%3B%3C/script%3E%20%23(%22

successful validated captcha in session not deleted

Hi

The environment has a session.
An user commits a contact form with captcha.
Captcha is valid (controller based) and will be deleted in database but not in the session.
If the user calls the contact form again, then the captcha image ist not shown.
The captcha key is still stored in the session but no longer in the database - so the image code in the form is wrong.

Edit:
This happens just in production environment
In production the captcha code will not be new generated.
The method ViewHelper::show_simple_captcha is not called again.
In Middleware::call -> Middleware::make_image -> Utils::simple_captcha_value(code) the SELECT Satement don't get a result and the captcha image is empty

Regards
Thomas

version 0.3.4 seems incompatible with ImageMagick-6.4.3.6-7.30.1

After upgrading to simple-captcha2 0.3.4, I get this error:

StandardError (Error while running convert: convert: unrecognized evaluate operator Uniform-noise'. ): simple_captcha2 (0.3.4) lib/simple_captcha/utils.rb:17:inrun'
simple_captcha2 (0.3.4) lib/simple_captcha/image.rb:81:in generate_simple_captcha_image' simple_captcha2 (0.3.4) lib/simple_captcha/middleware.rb:42:inmake_image'
simple_captcha2 (0.3.4) lib/simple_captcha/middleware.rb:21:in `call'

That option doesn't appear to be available in this version:
% convert -list evaluate
Add
And
Divide
LeftShift
Log
Max
Min
Multiply
Or
Pow
RightShift
Set
Subtract
Xor

Could you either make it compatible with older versions, maybe by making newer options optional, or at least document the minimum version of ImageMagick required?

Integration with Devise

Hi,

I was wondering on how to implement this with Devise? Tried following the steps given but I get a PG::Undefined_Table error looking for simple_captcha_data table. I followed both Controller-based and Model-based examples. Any help would be appreciated.

Thank you.

EDIT: I think I got it now. I'll close this at a later time for reference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.