Skip to content

fix(isFQDN): enforce 253-char domain length unless ignored - #2899

Open
ump45nose wants to merge 1 commit into
validatorjs:masterfrom
ump45nose:fix/2898-isFQDN-total-max-length
Open

ump45nose wants to merge 1 commit into
validatorjs:masterfrom
ump45nose:fix/2898-isFQDN-total-max-length

Conversation

@ump45nose

Copy link
Copy Markdown

Summary

isFQDN already documents ignore_max_length as skipping "the standard max length of a domain", but the implementation only enforced the per-label 63-character limit. Domains where every label is ≤63 could still exceed the RFC 1035 / RFC 3696 presentation-form limit of 253 characters and be accepted.

This rejects strings longer than 253 after trailing-dot / wildcard stripping, unless ignore_max_length is set.

Fixes #2898

Changes

  • src/lib/isFQDN.js: enforce str.length > 253 when ignore_max_length is false
  • test/validators.test.js + test/validators/isFQDN.test.js: regression coverage for 253/254/260 and the ignore option

Test plan

  • npm test (build + eslint + mocha) — 325 passing
  • CI on this PR

Notes

  • Defensive correctness fix for documented FQDN length limits; not a security disclosure.
  • AI assistance was used to help prepare and verify this change.

isFQDN already exposed ignore_max_length for "the standard max length
of a domain", but only enforced the per-label 63-char limit. Domains
with every label under 63 could still exceed the RFC 1035 / RFC 3696
presentation-form limit of 253 characters and be accepted.

Reject strings longer than 253 after trailing-dot / wildcard stripping
unless ignore_max_length is set, matching the documented option.

Fixes validatorjs#2898
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (2856862).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2899   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2601    +2     
  Branches       658       659    +1     
=========================================
+ Hits          2599      2601    +2     

☔ View full report in Codecov by Harness.
📢 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.

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.

isFQDN accepts domains longer than the 253-char / 255-octet limit

1 participant