?
avatar pe7er
pe7er
22 Apr 2020

In Joomla 4, the Google reCaptcha plugin seems broken.
The iframe with the Captcha is not loaded.
I've tested this issue also with the "System - HTTP Headers" plugin disabled, which gives the same result.

Steps to reproduce the issue

In Joomla 4 back-end:

  • Enable + configure the reCaptcha plugin:
    System > Plugins > open the reCaptcha plugin
    • Add a Site Key + Secret Key
    • Enable the plugin
  • Set reCaptcha as default CAPTCHA plugin
    System > Global Configuration > [Site] tab > Default Captcha: select "CAPTCHA - reCAPTCHA"
  • Create a contact form
    Components > Contacts > Contacts > New
    • Add "Test" Name + Email
  • Create menu item for contact form
    Menus > Main Menu > New >
    • Add menu title "Contact form"
    • Select "Menu Item Type": Contacts > Single Contact
    • Select "Contact": the "Test" contact that you've just created

On the front-end: Click on the "Contact form" menu item that you've just created.
At the bottom the form shows "Captcha * (optional)" but without the Google reCaptcha

j4-recaptcha-missing

Expected result

The contact form should contain the reCaptcha CAPTCHA to protect the form against spam abuse.

I would expect Joomla's contact form to contain an iframe where the reCaptcha would be loaded.
The following HTML code is the HTML Source from a contact form (com_contact) that I copied from a Joomla 3.9.x website:

<fieldset>
<div class="control-group">
<div class="control-label">
<label id="jform_captcha-lbl" for="jform_captcha" class="hasPopover required" title="" data-content="Vul de beveiligingscontrole in." data-original-title="Captcha">
Captcha<span class="star">&nbsp;*</span></label>
</div>
<div class="controls">
<div id="jform_captcha" class=" required g-recaptcha" data-sitekey="[xxx]" data-theme="light" data-size="normal" data-tabindex="0" data-callback="" data-expired-callback="" data-error-callback="" data-recaptcha-widget-id="0">
<div style="width: 304px; height: 78px;">
<div>
<iframe src="https://www.google.com/recaptcha/api2/anchor?[xxx]&amp;theme=light&amp;size=normal&amp;cb=kc6a5cbbomxn" width="304" height="78" role="presentation" name="a-n2pvm9ei6huv" frameborder="0" scrolling="no" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation allow-modals allow-popups-to-escape-sandbox">
</iframe>
</div>
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;">
</textarea>
</div>
<iframe style="display: none;">
</iframe>
</div>
</div>
</div>
</fieldset>

Actual result

In Joomla 4 the iframe is not loaded. The HTML source looks like:

<fieldset>
<div class="control-group">
<div class="control-label">
<label id="jform_captcha-lbl" for="jform_captcha" class="required">Captcha<span class="star" aria-hidden="true">&nbsp;*</span></label>
<span class="optional">(optional)</span>
</div>
<div class="controls"></div>
</div>
</fieldset>

Additional comments

I ran into this issue when coding a hCaptcha CAPTCHA alternative: #28613
My hCaptcha plugin works on Joomla 3.9.x but not on Joomla 4.
Hence I was looking at the default Google reCaptcha in Joomla 4 and ran into the same issue.

avatar pe7er pe7er - open - 22 Apr 2020
avatar joomla-cms-bot joomla-cms-bot - change - 22 Apr 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 Apr 2020
avatar pe7er pe7er - change - 22 Apr 2020
Title
[J4] reCaptcha not working
[4.0] reCaptcha not working
avatar pe7er pe7er - edited - 22 Apr 2020
avatar pe7er pe7er - change - 22 Apr 2020
The description was changed
avatar pe7er pe7er - edited - 22 Apr 2020
avatar pe7er pe7er - change - 22 Apr 2020
The description was changed
avatar pe7er pe7er - edited - 22 Apr 2020
avatar alikon
alikon - comment - 23 Apr 2020

maybe related to #28426 let's ping @Fedik for some more insight

avatar Fedik
Fedik - comment - 25 Apr 2020

The bug in Joomla\CMS\Captcha\Captcha
onInit(), onDisplay(), onCheckAnswer() is a callbacks and not an events

avatar Fedik
Fedik - comment - 25 Apr 2020

please test #28785

avatar alikon alikon - change - 25 Apr 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-04-25 10:02:39
Closed_By alikon
avatar alikon alikon - close - 25 Apr 2020
avatar pe7er
pe7er - comment - 25 Apr 2020

@Fedik Thanks for fixing this issue!

Add a Comment

Login with GitHub to post a comment