Skip to content

Conversation

@itsvelle
Copy link

Fixes #3549

This pull request improves the CAPTCHA hostname verification logic to be more robust and accurate, especially when dealing with parent domains returned by some CAPTCHA providers. The main changes introduce a new hostname matching function, update the verification logic to use it, and add tests to ensure correct behavior.

Hostname verification improvements:

  • Added a new normalize_hostname function to ensure hostnames are compared in a case-insensitive manner and without trailing dots.
  • Introduced the hostname_matches_site function, which allows the CAPTCHA response hostname to match either exactly or as a parent domain of the site hostname. This accommodates providers that return only the registrable domain.
  • Updated the CAPTCHA verification logic in the Form implementation to use the new hostname_matches_site function instead of a strict equality check.

Testing improvements:

  • Added a new test module to verify the correctness of the hostname matching logic, including cases for exact matches, parent domains, similar suffixes, case insensitivity, and trailing dots.

@itsvelle itsvelle requested a review from a team as a code owner December 26, 2025 01:54
@CLAassistant
Copy link

CLAassistant commented Dec 26, 2025

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hCaptcha response strips subdomain

2 participants