Skip to content

fix(isStrongPassword): count repeated supplementary characters correctly - #2930

Open
FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix-password-supplementary-repeat-score-20261012
Open

FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix-password-supplementary-repeat-score-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown

With returnScore enabled, one unique 😀 earns 1.5 default points instead of 1, and two identical copies earn 2.5 rather than 1.5. The character map counts Unicode code points, but repeated-character scoring subtracts that count from UTF-16 string length, adding a fake repetition for each surrogate pair.

Count repeated occurrences directly from the existing character map. Boolean validation, minLength, category definitions, unique-character scoring and all scoring options remain unchanged. No grapheme/normalization feature or vulnerability claim is introduced.

Validation on Node 24.19.0 and 22.19.0:

  • Pristine complete npm test: 323 passing; final: 327 passing, including all builds/minification, full ESLint and coverage.
  • Exact new tests on original code: 3 failures / 1 control.
  • 100,200 Unicode score assertions and 75,150 pristine boolean comparisons per runtime across five exports pass.
  • Independent complete rerun plus 28,275 score checks and 56,550 boolean-parity checks pass. ASCII/BMP, paired/unpaired surrogates, combining characters and custom weights are covered.

Browser distributions were exercised in Node VM, not an actual browser. Other hosted Node versions and online checks are not claimed passed. Prepared and tested with AI assistance (OpenAI Codex); no human review is claimed.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable): existing API and scoring documentation remain applicable; no change needed.
  • Tests written (where applicable)
  • References provided in PR (where applicable): concrete reproductions above; no data-format change.

Count repeated code-point occurrences from the existing character map instead of mixing UTF-16 length with unique code-point counts. Preserve boolean validation and minimum-length behavior.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 22:24
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.

1 participant