Problem/Motivation

Malformed markup emerging from turnstile_protect_captcha_alter causes the text < referrerpolicy="no-referrer"> to be displayed above the page content. See attached screenshot.

Steps to reproduce

There is a lot of configuration for captcha, turnstile, and this module, so I'm not sure if there is something unique about my case. So as far as I know, the steps to reproduce are simply to enable and configure this module.

The problem source appears to be here, where turnstile_protect_captcha_alter expects $captcha['form']['turnstile_widget']['#attached']['html_head'][0][0] to exist, and it doesn't. In fact, at this point, we have just a (empty) string at $captcha['form']['turnstile_widget']['#markup']

Proposed resolution

  1. Add a test for the existence of an array at $captcha['form']['turnstile_widget']['#attached']['html_head'][0][0] before adding attributes to it.
  2. Better yet, re-evaluate the purpose of this and make it work correctly (in all scenarios).

Remaining tasks

User interface changes

API changes

Data model changes

Comments

pdcarto created an issue. See original summary.

joecorall’s picture

I agree there could be better requirements checking/alerting for this module.

Though this module's instructions do say you need to configure the turnstile module's settings (at /admin/config/people/captcha/turnstile). As a stop-gap around this issue before adding better checks, have you done that?

joecorall’s picture

Status: Active » Postponed (maintainer needs more info)
pdcarto’s picture

Yes, turnstile is configured and working. Settings appear to be very straightforward (screenshot attached).

joecorall’s picture

Status: Postponed (maintainer needs more info) » Active

Thanks for confirming. Looks like a code change was made on the dependent module: https://git.drupalcode.org/project/turnstile/-/commit/55638999e8ed960582...

I'll get a patch in

  • 4502ed81 committed on 1.0.x
    Issue #3513075: Malformed challenge markup
    
    Fix turnstile module's new...
joecorall’s picture

Status: Active » Fixed

Fixed with latest release 1.0.3. Thank you for reporting!

pdcarto’s picture

Thanks Joe!!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.