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
- Add a test for the existence of an array at
$captcha['form']['turnstile_widget']['#attached']['html_head'][0][0]before adding attributes to it. - 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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | screencapture-acdc-amherst-edu-admin-config-people-captcha-turnstile-2025-03-14-13_28_41.png | 202.8 KB | pdcarto |
| Screenshot from 2025-03-14 12-20-54.png | 382.46 KB | pdcarto |
Comments
Comment #2
joecorall commentedI 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?Comment #3
joecorall commentedComment #4
pdcarto commentedYes, turnstile is configured and working. Settings appear to be very straightforward (screenshot attached).
Comment #5
joecorall commentedThanks 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
Comment #7
joecorall commentedFixed with latest release 1.0.3. Thank you for reporting!
Comment #8
pdcarto commentedThanks Joe!!!