Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone ZF2 forms: Captcha Dumb value is always wrong #4

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Standalone ZF2 forms: Captcha Dumb value is always wrong #4

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Member

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7098
User: @developer10
Created On: 2015-01-04T12:53:51Z
Updated At: 2015-01-05T10:27:52Z
Body
I first tried to use it without session at all but then included it like so:

$sessionManager = new Zend\Session\SessionManager();
$sessionManager->start();

After I enter the "word" my session outputs:

[Zend_Form_Captcha_0567fd5c45db3ad9136610ee3e10d71a] => Zend\Stdlib\ArrayObject Object
        (
            [storage:protected] => Array
                (
                    [word] => 74c74
                )

            [flag:protected] => 2
            [iteratorClass:protected] => ArrayIterator
            [protectedProperties:protected] => Array
                (
                    [0] => storage
                    [1] => flag
                    [2] => iteratorClass
                    [3] => protectedProperties
                )

        )

but the problem is that getMessages contains (see below) as if the word was entered incorrectly. I tried entering both backwards and normal way, the result is always the same: Captcha value is wrong

Array
(
    [captcha] => Array
        (
            [badCaptcha] => Captcha value is wrong
        )

)

Comment

User: @Ocramius
Created On: 2015-01-05T00:38:43Z
Updated At: 2015-01-05T00:38:43Z
Body
Requires an actual failing test case, I'd say. Session issues are always tricky to handle, therefore I suggest writing a small test.


Comment

User: @developer10
Created On: 2015-01-05T10:27:52Z
Updated At: 2015-01-05T10:27:52Z
Body
This may not be a bug or anything after all. I have put some print_r() in the class AbstractWord to see what the input value is actually compared to.

$this->id = $value['id'];
if ($input !== $this->getWord()) {

        echo '<pre>';
        print_r("Input: " . $input);
        print_r(" | getWord: " . $this->getWord());
        echo '</pre>';


        $this->error(self::BAD_CAPTCHA);
        return false;

The following happens:

The word is created, user inputs the value in the captcha field. But then when my form is submitted, a new request is being made so that the captcha input is actually being compared to the new word (from that subsequent request).

I assume I'm doing something incorrectly because I intentionally fill the other fields incorrectly and try to get the validation errors appear. They don't appear at all (maybe because of that new request; also my form is blank after that) and the only way I can see the errors is by outputting them below the form by calling echo on $form->getMessages().

Bearing in mind I'm implementing a standalone form and having a custom InputFilter class - why my form is submitting and the errors (including captcha one) are not appearing even though field values are incorrect?



Originally posted by @GeeH at zendframework/zend-captcha#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant