Skip to content

Hostname label length validation #877

@DannyvdSluijs

Description

@DannyvdSluijs

In the drafts 3, and 4 we are doing hostname validation but we aren't checking for maximum label length. These are optional testcases which are skipped if failing.

The maximum label length of 63 characters and hostname rules come from RFC 1035 (Domain Names — Implementation and Specification), specifically:

Section 2.3.4: "Name space specifications and limitations"
Each label is 63 octets or less.
The total domain name (including dots) is limited to 255 octets.
RFC 1123 (Requirements for Internet Hosts — Application and Support) later clarifies that hostnames can include letters, digits, and hyphens, but still adheres to the 63-character label limit.

You can see them being skipped in the test output:

15) JsonSchema\Tests\JsonSchemaTestSuiteTest::testTestCaseValidatesCorrectly with data set "[draft3/optional/format/host-name.json]: validation of host names: exceeds maximum label length is expected to be invalid" ('validation of host names', 'exceeds maximum label length', stdClass Object (...), 'abcdefghijklmnopqrstuvwxyzabc...kl.com', 1, JsonSchema\DraftIdentifiers Object (...), false, true)
Optional test case would fail
24) JsonSchema\Tests\JsonSchemaTestSuiteTest::testTestCaseValidatesCorrectly with data set "[draft4/optional/format/hostname.json]: validation of host names: exceeds maximum label length is expected to be invalid" ('validation of host names', 'exceeds maximum label length', stdClass Object (...), 'abcdefghijklmnopqrstuvwxyzabc...kl.com', 1, JsonSchema\DraftIdentifiers Object (...), false, true)
Optional test case would fail

Draft 6 (and 7 in #847) use a regex which limits the length whereas draft 3 and 4 use a regex without length limitation

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions