Repository navigation
Reject a trailing label separator in idn-hostname - #1384
Conversation
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#1377 still accepted one trailing separator. Reject it, and re-enable the 16 upstream cases that were disabled for it.
|
Review of this PR (head 1. 2.x backport #1383 will disagree with master ( 2. 3. The test comment overstates the matrix ( |
|
A note on whether to merge this, separate from the code review above. This is a conformance choice rather than a bug fix. The case for merging: the upstream JSON-Schema-Test-Suite marks The case against: Recommendation: merge this only if the project wants to follow the upstream suite strictly. In that case:
If the project would rather not break callers that pass FQDNs, close this and leave the four trailing-separator suite cases disabled with their reason. Either choice is defensible; it is a policy decision for the maintainers. |
…y separator and label kind The trailing-separator rejection gets its own Breaking changes entry in Unreleased, because 3.0.9 and earlier accepted example. and an upgrade now rejects it. It no longer reads as part of the networknt#1377 entry. labelCount was only needed to drop one trailing empty label, so labels.length is used directly. rejectsTrailingLabelSeparators now tries all four separators after an ASCII label, a U-label and an A-label, alone and as the last label of a two-label name. Each name is first asserted valid without the separator, so the rejection is caused by the trailing separator alone.
|
Thanks for the note on whether to merge. I'd go with the upstream suite, so If it goes in, both of your conditions are done:
From the code review:
Full suite with this commit: 10,945 tests, 0 failures, 45 skipped. |
|
Review of head 1. 2.x and master disagree until #1386 lands ( 2. Run-on 3. No format-level test ( |
The isValid Javadoc lists the rules instead of joining them in the @return sentence, and names leading and doubled separators along with the trailing one. idnHostnameFormatRejectsTrailingLabelSeparator checks the IdnHostnameFormat contract directly, not only RFC5892.isValid.
…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.
Full suite with this commit: 10,946 tests, 0 failures, 45 skipped. |
* Reject a trailing label separator in idn-hostname on 2.x Port of #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. #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. * Address review: 2.x CHANGELOG wording, list the rules, test the format 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 #1386 and #1384. Also ports the #1384 review changes: the isValid Javadoc lists the rules, and idnHostnameFormatRejectsTrailingLabelSeparator checks the IdnHostnameFormat contract directly.
|
Review of head
The full suite passes on JDK 25: 10946 tests, 0 failures, 45 skipped, and the new test runs. |
Reject a trailing label separator in idn-hostname
Follow-up to #1377, as mentioned there: the JSON-Schema-Test-Suite treats a name ending in a label separator as an invalid
idn-hostname, and #1377 still accepted a single one.RFC5892.isValidno longer drops a trailing empty label, soexample.,example。,example.andexample。are rejected along with the other empty labels.hostnamealready rejects a trailing dot through its pattern, so the two formats now agree.idn-hostname.jsonfiles (draft 7, 2019-09, 2020-12 and draft-next), 16 in all.RFC5892Test.rejectsTrailingLabelSeparatorstries each of the four separators after an ASCII label, a U-label and an A-label (12 combinations), alone and as the last label of a two-label name, and first asserts each name is valid without the separator. The 253-character test now expectsname253 + "."to be invalid.example.and an upgrade now rejects it. The Reject over-long hostnames and invalid A-labels in the hostname format #1377 entry no longer mentions trailing separators, and the known-limits line keeps only UTS 46 mapping.This is a conformance choice:
example.is a valid fully-qualified name with the root dot. Merging means following the upstream suite strictly; if you'd rather keep accepting FQDNs, this can be closed and the four suite cases left disabled.2.x port: #1386 (same change on
2.xafter #1383).The UTS 46 mapping cases stay disabled. That's a separate, larger change.