You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Captchas not being generated in versions > 0.3.2. #50
After a recent upgrade I noticed that captchas were not showing up:
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>'
Looks like the problem is happening when SimpleCaptcha::Utils::run appends '2>&1' to the end of the convert command. Anything on STDERR gets redirected into STDOUT, and borks up the image data stream (if I understand this correctly). It also hides whatever was sent to STDERR.
Removing the redirection resulted in a valid captcha image and the error being displayed in the rails server console:
Fontconfig warning: ignoring C.UTF-8: not a valid language tag
in my case
Reacted by Philipp, Sascha Steinbiss and Dmitry Halai
hmm interesting, so that bug only happens if there are some encodings wrong, that's why I never ran into it.
I think we could just try to mute the errors in general "> /dev/null" instead. Best option would be using popen3 or similar to seperate the error and stdout stream.
@zealot128 I think it's simpler than that. Just let the errors go to stderr instead of redirecting them, then the OS can handle them. Alternately, make the redirection an option, so they can easily be muted.
I'm not sure this solution is safe enough, but it works. If someone can tell how to improve security - I will be grateful. Maybe you need to update README. Thank you!
Activity
IanBurry commentedon Mar 18, 2016
I'm seeing the same problem
However, it's working just fine on my MacBook Pro
IanBurry commentedon Apr 2, 2016
Looks like the problem is happening when SimpleCaptcha::Utils::run appends '2>&1' to the end of the convert command. Anything on STDERR gets redirected into STDOUT, and borks up the image data stream (if I understand this correctly). It also hides whatever was sent to STDERR.
Removing the redirection resulted in a valid captcha image and the error being displayed in the rails server console:
Fontconfig warning: ignoring C.UTF-8: not a valid language tag
in my case
zealot128 commentedon Dec 21, 2016
hmm interesting, so that bug only happens if there are some encodings wrong, that's why I never ran into it.
I think we could just try to mute the errors in general "> /dev/null" instead. Best option would be using popen3 or similar to seperate the error and stdout stream.
IanBurry commentedon Dec 23, 2016
@zealot128 I think it's simpler than that. Just let the errors go to stderr instead of redirecting them, then the OS can handle them. Alternately, make the redirection an option, so they can easily be muted.
Melancholic commentedon Mar 12, 2017
Hello!
Having understood the question, I came to the conclusion that this error was the result of the update of the ImageMagick policy. Link to the relevant news: https://www.imagemagick.org/discourse-server/viewtopic.php?f=4&t=29588.
The following solution helped me:
I'm not sure this solution is safe enough, but it works. If someone can tell how to improve security - I will be grateful. Maybe you need to update README. Thank you!
jagdeepsingh commentedon Dec 27, 2017
Upgrading imagemagick to version 7.0.7-15 solved the issue for me.
renji001 commentedon Feb 16, 2020
delete '2>&1' worked for me !
imageMagick 6.7.8
fyi