cgsmith / zf1-recaptcha-2

Zend Framework 1 integration for Google reCAPTCHA version 2.0
MIT License
9 stars 11 forks source link

Fails to validate when PHP setting arg_separator.output = '&' #19

Open LosHawlos opened 7 years ago

LosHawlos commented 7 years ago

Tracked down an issue in our PHP setup where the captcha failed to validate. Google server response: "missing-input-response"

It is caused by our PHP INI that has the setting: arg_separator.output = "&"

This leads to the query string generated using http_build_query() to be concatenated by the separator & which makes the google server fail to parse the post parameters.

My fix is to force it to use a single '&' in /Validate/Recaptcha.php#L81:

    $queryString = http_build_query([
        'secret'   => $this->_secretKey,
        'response' => $value,
        'remoteIp' => $_SERVER['REMOTE_ADDR']
    ], '', '&');
cgsmith commented 7 years ago

Nice work tracking that down! The separator output is default of & - do you have it as & for some reason?