Skip to content

Reject a trailing label separator in idn-hostname on 2.x - #1386

Merged
stevehu merged 2 commits into
networknt:2.xfrom
ravismash:fix/idn-hostname-trailing-separator-2.x
Nov 9, 2026
Merged

stevehu merged 2 commits into
networknt:2.xfrom
ravismash:fix/idn-hostname-trailing-separator-2.x

Conversation

@ravismash

@ravismash ravismash commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Port of #1384 to 2.x, so 2.x and master agree on example. after #1383.

  • RFC5892.isValid no longer drops a trailing empty label, so example., example。, example. and example。 are rejected. labelCount is removed.
  • Re-enables the 16 trailing-separator cases in the vendored idn-hostname.json files.
  • RFC5892Test: acceptsAtMostOneTrailingLabelSeparator becomes rejectsTrailingLabelSeparators (four separators x three label kinds), and the 253-character test expects name253 + "." to be invalid.
  • idnHostnameFormatRejectsTrailingLabelSeparator checks IdnHostnameFormat directly.
  • CHANGELOG: the Breaking changes entry says an empty label (a leading, doubled or trailing separator) is rejected; 2.0.8 accepted all three. The known-limits line keeps only UTS 46 mapping, and the suite-files line no longer mentions trailing-separator cases.

RFC5892.java is identical to master after #1384, including its review changes. The test file keeps 2.x's Java 8 adaptations.

Tested on Java 24: the 74 GraalJS regex test errors (Unsafe.ensureClassInitialized was removed in Java 22) also occur on 2.x without this change; every other test passes.

Port of networknt#1384 to 2.x. The JSON-Schema-Test-Suite treats a trailing
label separator (example., example。, example., example。) as an
invalid idn-hostname, and hostname already rejects a trailing dot.
networknt#1383 still accepted one trailing separator on 2.x. Reject it, so
2.x and master agree, and re-enable the 16 upstream cases that were
disabled for it.
@codecov-commenter

codecov-commenter commented Nov 8, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (2.x@713aaec). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@          Coverage Diff           @@
##             2.x    #1386   +/-   ##
======================================
  Coverage       ?   81.31%           
  Complexity     ?     2413           
======================================
  Files          ?      210           
  Lines          ?     7478           
  Branches       ?     1409           
======================================
  Hits           ?     6081           
  Misses         ?      959           
  Partials       ?      438           

☔ 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.

@stevehu

stevehu commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Review of head d20177d. I found no code defect. RFC5892.java is identical to the #1384 version, the four re-enabled idn-hostname.json files match master's, and the trailing-separator test matches master's. The full suite passes on JDK 11 (10780 tests, 0 failures, 17 skipped) and JDK 21 (10780 tests, 0 failures, 16 skipped). I could not run Java 8. Four minor points, all in the CHANGELOG and tests, most-severe first.

1. Wrong version in the entry (CHANGELOG.md:14)
"Released versions up to 3.0.9 accepted any number of them" was copied from master. 3.0.9 is not a 2.x release; the latest is 2.0.8, which does accept example., example.., xn--4dbc. and example。. It should say 2.0.8.

2. Leading and doubled separators are not mentioned (CHANGELOG.md:14)
I probed 2.0.8 against this branch: .example and a..b are valid on 2.0.8 and invalid here, because 2.0.8 skipped empty labels and the new code rejects every one. The entry lists only trailing separators. Extend it to "an empty label, such as a leading, doubled or trailing separator".

3. Link (CHANGELOG.md:14)
The entry links only #1384, not this PR. Link #1386, and optionally #1384 for the rationale.

4. No format-level test (RFC5892Test.java:354)
The rejection is asserted only on RFC5892.isValid. A one-line assertFalse(new IdnHostnameFormat().matches(null, "example.")) would pin the contract on 2.x.

…t class

The entry names 2.0.8, the latest 2.x release, which skipped empty
labels: .example, a..b and example. were all valid there. It now
covers leading and doubled separators too, and links networknt#1386 and networknt#1384.

Also ports the networknt#1384 review changes: the isValid Javadoc lists the
rules, and idnHostnameFormatRejectsTrailingLabelSeparator checks the
IdnHostnameFormat contract directly.
@ravismash

Copy link
Copy Markdown
Contributor Author
  1. The entry now says 2.0.8.
  2. Reworded to "an empty label, such as a leading, doubled or trailing label separator", with .example, a..b, example. and example。 as examples. I checked RFC5892.isValid at the 2.0.8 tag: it skipped every empty label, so all four were valid there. 3.0.9 already rejected leading and doubled separators, so the master entry stays as it is.
  3. The entry links Reject a trailing label separator in idn-hostname on 2.x #1386 and Reject a trailing label separator in idn-hostname #1384.
  4. Added idnHostnameFormatRejectsTrailingLabelSeparator, as on Reject a trailing label separator in idn-hostname #1384. This commit also ports Reject a trailing label separator in idn-hostname #1384's Javadoc change, so RFC5892.java is still identical on both branches.

RFC5892Test passes, all 360 enabled idn-hostname suite cases pass, and the changed files compile with --release 8.

@stevehu
stevehu merged commit cf6ab7a into networknt:2.x Nov 9, 2026
4 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