Skip to content

Conversation

@longwave
Copy link
Contributor

The implementation of RFC 3986 in the URI validator is more strict than the specification allows. While the RFC says

URI producers should use names that conform to the DNS syntax, even when use of DNS is not immediately apparent

the host component grammar actually allows more characters than are allowed in DNS names.

This is a problem for the Drupal project which uses this package in conjunction with custom stream wrappers with module names in the host component. Module names conform to PHP function name standards, not DNS standards - that is, they allow underscores but not dashes.

The relevant RFC grammar is

      host        = IP-literal / IPv4address / reg-name

      reg-name    = *( unreserved / pct-encoded / sub-delims )

      unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

This PR widens the host validation to allow all characters in the unreserved set. While pct-encoded and sub-delims are also technically allowed, this is the smallest change that will help us out.

Copy link
Collaborator

@DannyvdSluijs DannyvdSluijs 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 the PR, nice work. I've left one small suggestion on the test to also include a test case for the tilde character.
Could you also add an entry in the CHANGELOG.md ? This way I can merge the PR without adjustments with saves me some time.

Once done it should be easy to create a new release and the issue in your project(s) should be resolved.

longwave and others added 3 commits November 28, 2025 14:57
Co-authored-by: Danny van der Sluijs <danny.vandersluijs@icloud.com>
@longwave longwave changed the title Allow more characters in URI hostnames as per RFC 3986 Allow underscore and tilde in URI hostnames as per RFC 3986 Nov 28, 2025
@DannyvdSluijs DannyvdSluijs merged commit 8ca5769 into jsonrainbow:main Nov 28, 2025
17 checks passed
@DannyvdSluijs
Copy link
Collaborator

Version 6.6.2 was released, see https://github.com/jsonrainbow/json-schema/releases/tag/6.6.2

@longwave
Copy link
Contributor Author

Thank you for the super fast response!

@wimleers
Copy link

WOW! Incredible!

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