ZF-10627: Captcha string out of image


Sometimes captcha string is printed out of image so it is not visible.

class: Zend_Captcha_Image line 488: imagefilledrectangle($img, 0, 0, $w-1, $h-1, $bg_color); $textbox = imageftbbox($fsize, 0, $font, $word); $x = ($w - ($textbox[2] - $textbox[0])) / 2; $y = ($h - ($textbox[7] - $textbox[1])) / 2;

Don`t now why but sometimes $x gets huge value over 1000000. Probably there is some bug in imageftbbox function. I found that many other developers have same problem with captcha. Protection for $x value (maybe y also) will be very helpful because we (developers) do not have any possibility to protect our code. As result we get image with dots and lines but without any code.


Can you provide the configuration of the Captcha object?

class Core_Form_Element_Captcha_Image extends Zend_Form_Element_Captcha { public function __construct( $Name, $Options = null ) { $captchaImage = new Zend_Captcha_Image( 'captchaImg' );
$captchaImage->setFontSize(36) ->setLineNoiseLevel( 2 )
->setFont( APPLICATION_PATH . '/../public/fonts/12tonfishstick.ttf' )
->setWidth(176) ->setHeight(75);

    $Options['captcha'] = $captchaImage;

    parent::__construct( $Name, $Options );


It doesn`t happen very often. Sometimes I need to generate many captcha to get it.