Skip to content

fix: normalize captcha display text to lowercase when case_sensitive is false#2

Merged
shazeedul merged 2 commits into
mainfrom
copilot/fix-captcha-case-sensitivity
May 10, 2026
Merged

fix: normalize captcha display text to lowercase when case_sensitive is false#2
shazeedul merged 2 commits into
mainfrom
copilot/fix-captcha-case-sensitivity

Conversation

Copilot AI commented May 10, 2026

Copy link
Copy Markdown
Contributor

When case_sensitive = false (the default), the captcha image could render mixed-case text like AbCdEf while silently accepting ABCDEF — technically correct but visually misleading, since the image implies a specific casing that isn't enforced.

Changes

  • TextGenerator::generate() — sets question (rendered in image) to mb_strtolower($text) when caseSensitive is false; answer remains the original text and flows through the existing normalize() path unchanged
return new CaptchaChallenge(
    id: bin2hex(random_bytes(16)),
    question: $caseSensitive ? $text : mb_strtolower($text),
    answer: $text,
    caseSensitive: $caseSensitive,
);
  • CaptchaGenerationTest — adds coverage for:
    • displayed text is lowercase when case_sensitive = false
    • original casing preserved in image when case_sensitive = true (uses a fixed all-uppercase character pool to avoid flakiness)
    • all-caps input accepted when insensitive; wrong-case rejected when sensitive

Copilot AI and others added 2 commits May 10, 2026 05:10
@shazeedul shazeedul marked this pull request as ready for review May 10, 2026 05:43
@shazeedul shazeedul merged commit 9dd08ef into main May 10, 2026
50 of 53 checks passed
@shazeedul shazeedul deleted the copilot/fix-captcha-case-sensitivity branch May 10, 2026 05:44
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.

2 participants