Skip to content

ReCaptcha in GoogleCaptchaValidator.php is likely never validated due to always-false condition #335

Description

@koenig-digital

Bug Report

Affected File:
Classes/Domain/Validator/GoogleCaptchaValidator.php

TYPO3 Version:
12.x

Blog Extension Version:
13.x


Description

It seems that the if condition in GoogleCaptchaValidator might be logically incorrect, preventing the Google reCAPTCHA validation from ever running.

In my setup, I’m able to submit comments even when the reCAPTCHA checkbox is not checked.


Problematic Code

&& (!(bool)($requestData['action'] ?? null) && $requestData['action'] === $action)
&& (!(bool)($requestData['controller'] ?? null) && $requestData['controller'] === $controller)

In a typical scenario, the action is "form", which means:

$requestData['action'] ?? null returns "form"

(bool) "form" evaluates to true

!true is false

Therefore, this part of the condition is always false, even when $requestData['action'] === $action.

The same applies to controller.

Expected Behavior
The reCAPTCHA should be validated when the action and controller match the expected values.

Suggested Fix
Consider replacing the condition with something like:

(!isset($requestData['action']) || $requestData['action'] === $action)

Same logic for controller.

Let me know if I misunderstood the intended behavior. Thanks for maintaining the extension!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions