Skip to content

Conversation

@koral--
Copy link
Contributor

@koral-- koral-- commented Oct 18, 2025

Previously, the validator would subtract all Unicode variation selectors (\uFE0F, \uFE0E) from a string's total length. This allowed for a string to contain a potentially infinite number of these characters while still passing a max length validation. For example, a string like "test\uFE0F\uFE0F\uFE0F..." could easily bypass a max: 4 check.

Variation selectors are now only discounted from the length if they directly follow a base character they are modifying. If they appear at the start of a string or in a sequence, they are correctly counted towards the total length.

References:

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR! Can you move the existing isLength tests to the new file as well? And rebase upon the master branch so CI passes?

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f2e3633) to head (0568fb7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2616   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2566      2566           
  Branches       651       651           
=========================================
  Hits          2566      2566           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@WikiRik WikiRik requested a review from rubiin November 5, 2025 17:30
@WikiRik WikiRik changed the title Fix(isLength): Correctly handle Unicode variation selectors fix(isLength): correctly handle Unicode variation selectors Nov 5, 2025
@rubiin rubiin merged commit d457eca into validatorjs:master Nov 5, 2025
12 checks passed
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