Commit 8ca5769
Allow underscore and tilde in URI hostnames as per RFC 3986 (#853)
The implementation of [RFC
3986](https://datatracker.ietf.org/doc/html/rfc3986) 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.
---------
Co-authored-by: Danny van der Sluijs <danny.vandersluijs@icloud.com>1 parent fd8e5c6 commit 8ca5769
File tree
3 files changed
+5
-1
lines changed- src/JsonSchema/Tool/Validator
- tests/Tool/Validator
3 files changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
0 commit comments