[Catalyst] Announce: CatalystX::Controller::reCAPTCHA

Bill Moseley moseley at hank.org
Sat Oct 6 00:29:22 GMT 2007


I'm wondering about the code a little:

$result is an empty hash, and so if there's no request parameter
the "else" is going to get an empty hash, but $result->{is_valid}
and $result->{error} are used in that else block:

    my $result = {};
    if ( $c->req->param( 'recaptcha_response_field' ) ) {
        $result = $cap->check_answer(
            $c->config->{recaptcha}->{priv_key}, $ENV{'REMOTE_ADDR'},
            $c->req->param('recaptcha_challenge_field'),
            $c->req->param('recaptcha_response_field')
        );
    }
    else {
        $c->stash->{recaptcha_ok} = $result->{is_valid};
        $c->stash->{recaptcha_error} = $result->{error} || "User appears not to have submitted a recaptcha";
    }

Then this doesn't look correct, either.

    if ( $result->{is_valid} ) {
        $c->stash->{recaptcha_ok} = 1;
    }
    else {
        $c->stash->{recaptcha_ok} = $result->{error};
    }


I'll be happy to send a patch if you like.



-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list