Skip to content

Conversation

@caseylocker
Copy link

Summary

  • Fixes password validation incorrectly rejecting passwords containing hyphens
  • The hyphen was positioned as *-+ in the regex character class, causing it to be interpreted as a range operator (ASCII 42-43) instead of a literal hyphen (ASCII 45)
  • Moving hyphen to end of character class (*+-) ensures it's treated as a literal character

Root Cause

Regression introduced in commit 757e964 (fix/password-special-characters branch). When + was added to the allowed special characters, it was placed after the hyphen, changing *-] (valid) to *-+] (range).

Test plan

  • Verify password with hyphen (e.g., Test-Pass1!) now passes validation
  • Verify password with asterisk (e.g., Test*Pass1!) still passes validation
  • Verify password with plus sign (e.g., Test+Pass1!) passes validation
  • Verify passwords missing required character types still fail validation

🤖 Generated with Claude Code

The hyphen character was positioned between * and + in the regex
character class [#?!@$%^&*-+], causing it to be interpreted as a
range operator (ASCII 42-43) instead of a literal hyphen (ASCII 45).

This caused passwords containing hyphens to fail validation while
passwords with asterisks passed.

Moving the hyphen to the end of the character class [#?!@$%^&*+-]
ensures it is treated as a literal character.

Regression introduced in 757e964.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a regex bug in password validation that was incorrectly rejecting passwords containing hyphens. The hyphen character was positioned in the middle of a character class (*-+), causing it to be interpreted as a range operator (ASCII 42-43) instead of a literal hyphen character (ASCII 45). This regression was introduced when the + character was added to the allowed special characters.

Changes:

  • Moved hyphen from middle to end of character class in all three password configuration regex patterns
  • Updated password_allowed_special_characters, password_shape_pattern, and password_shape_warning to use *+- instead of *-+

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@smarcet smarcet self-requested a review January 27, 2026 23:35
@smarcet smarcet force-pushed the hotfix/password-hyphen-validation branch from a6889ac to fbb9ec8 Compare January 28, 2026 00:06
Copy link
Collaborator

@smarcet smarcet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants