Skip to content

Commit

Permalink
Add referrer policy to cloudflare JS
Browse files Browse the repository at this point in the history
  • Loading branch information
maccabeelevine authored and joecorall committed Nov 18, 2024
1 parent a1885ee commit 708a439
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions turnstile_protect.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function turnstile_protect_captcha_alter(&$captcha, $info) {
return;
}

// Block referrer to cloudflare.
$captcha['form']['turnstile_widget']['#attached']['html_head'][0][0]['#attributes']['referrerpolicy'] = 'no-referrer';

// Add a javascript callback after the turnstile succeeds.
$captcha['form']['turnstile_widget']['#markup'] = str_replace('<div', '<div data-callback="turnstileProtectAutoSubmit"', $captcha['form']['turnstile_widget']['#markup']);
$captcha['form']['#attached']['library'][] = 'turnstile_protect/challenge';
Expand Down

0 comments on commit 708a439

Please sign in to comment.