Problem/Motivation
Google's NoCAPTCHA ReCAPTCHA failed to verify even though everything was correct on the front end. Upon further investigation, the error returned by Google is missing-input-response. The issue is caused by the call to http_build_query on line 101 of RequestParameters.php. The default argument separator is the one specified by the PHP ini directive: arg_separator.output. PHP's default is & but Drupal's is &. When using the & separator, the verification querystring becomes something similar to ...../?blah&response= which submits a parameter called amp;response to Google instead of response.
Drupal sets arg_separator.output in settings.php to &. If you change this to &, everything works fine.
Proposed resolution
Change return http_build_query($this->toArray()); to return http_build_query($this->toArray(), null, '&'); to force using the correct argument separator, since it doesn't really make sense to use an argument separator other than &.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | recaptcha-force-argument-seperator-2476057-13.patch | 477 bytes | martini9011 |
Comments
Comment #1
spadusa commentedComment #2
hass commentedWTF is this? Why does Drupal change this? We can do a quick fix here, but we need to fix this in the lib...
How can I repro the issue? Until now I have not seen any fail in over 100 tests.
Comment #3
hass commentedIt looks like this ini sets have been removed over 6 years ago from settings.php, see #303154: Document ini_set() calls in default.settings.php.
How old is your settings.php? You may like to cleanup your setting.php and the issue is solved.
We should document this as a known issue in readme.txt.
Comment #4
hass commentedAfter some investigation on D5/D6 code I can confirm that
arg_separator.outputis set there as you reported. I cannot find it in D7 as Dries removed it in the linked case. It was also not moved into .htaccess. I also checked all my sites and found one site that was upgraded from D6 to D7 that still has these directives set in settings.php. Another site has not.Moving forward, I will add a check to hook_requirement and link the case and tell users to remove the complete ini_set() code block if it is still there.
Replace the following code in settings.php (settings still required by D7 are set in .htaccess just as a note):
with this code and you have a D7 settings.php
Thank you very much for reporting this issue.
Comment #5
hass commentedIt's not a bug, it's a feature... :-(
Comment #6
hass commentedAdded a book page https://www.drupal.org/node/2476237
Comment #8
hass commentedComment #11
zach.bimson commentedI ran into this issue when pushing code to pantheon, my local was set up and was working (i assume due to the settings file config) yet when i pushed, it was breaking.. i implemented the proposed solution and it works perfectly.
Can we get this committed ? shall i make a quick patch ?
Comment #12
drupal-son commentedSame issue.
I'm running the site on Pantheon.
I can't change the php.ini.
My settings.php there isn't any of those lines.
Adding ini_set('arg_separator.output', '&'); to my settings.php solve the issue.
Thanks.
Comment #13
martini9011 commentedCreated a patch for the 2.0 version of the module since I am unable to switch to dev at the moment, might be handy for anyone else with this same case.
The patch contains the proposed resolution by spadusa, and as confirmed in #11 works correctly.
Comment #14
issa.haddadinI'm still facing the same problem, it is still happening on the dev version or using the stable version with comment #13 patch.
Comment #15
hass commented