genemu / GenemuFormBundle

Extra Form : Captcha GD, Tinymce, Recaptcha, JQueryDate, JQueryAutocomplete, JQuerySlider, JQueryFile, JQueryImage
587 stars 265 forks source link

Switch endpoint to api/siteverify and json response #387

Open gehaxelt opened 9 years ago

gehaxelt commented 9 years ago

Hi,

I recently had an issue that the bundle wasn't able to validate the captchas. It seemed like the limit of allowed requests to /verify was exhausted thus always returning false.

Having a look at the current backend-validation documention by google (https://developers.google.com/recaptcha/docs/verify), I'd recommend to switch to the following endpoint: https://www.google.com/recaptcha/api/siteverify.

However, this particular endpoint returns a JSON response. Afaik, the current code can't handle JSON responses as it splits the response into seperate lines and compares the first line against true.

Are others having a similar issue?

Fixing this shouldn't be too hard. You could try to parse the JSON response. In case that fails, fallback to the current (line-splitting) validation. Probably changing the default settings to use the newer endpoint is a good idea.

Kind regards, gehaxelt