Skip to content

Commit 1ebccb1

Browse files
do not verify TLD in hostname, idn-hostname formats
see json-schema-org/JSON-Schema-Test-Suite#760
1 parent f3ba00d commit 1ebccb1

12 files changed

+17
-70
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for JSON-Schema-Modern
22

33
{{$NEXT}}
4+
- update 'hostname' and 'idn-hostname' format validation to be more
5+
lax with respect to domain names; fixes some acceptance tests
46

57
0.604 2025-03-08 23:23:05Z
68
- mark some failing format tests as todo that will be added in

lib/JSON/Schema/Modern/Vocabulary/FormatAssertion.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ sub keywords ($class, $spec_version) {
4545
my $is_hostname = sub { # hostname, idn-hostname
4646
# FIXME: draft7 hostname uses RFC1034, draft2019-09+ hostname uses RFC1123
4747
require Data::Validate::Domain;
48-
Data::Validate::Domain::is_domain($_[0]);
48+
Data::Validate::Domain::is_domain($_[0],
49+
{ domain_disable_tld_validation => 1, domain_allow_single_label => 1 });
4950
};
5051
my $idn_decode = sub { # idn-hostname
5152
require Net::IDN::Encode;

t/results/draft2019-09-acceptance-format.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ date-time.json 25 0 0
1111
date.json 47 0 0
1212
duration.json 26 0 0
1313
email.json 15 0 0
14-
hostname.json 20 5 0
14+
hostname.json 25 0 0
1515
idn-email.json 10 0 0
16-
idn-hostname.json 37 21 0
16+
idn-hostname.json 43 15 0
1717
ipv4.json 16 0 0
1818
ipv6.json 40 0 0
1919
iri-reference.json 11 2 0
@@ -28,4 +28,4 @@ uri-template.json 9 1 0
2828
uri.json 25 1 0
2929
uuid.json 21 0 0
3030
---------------------------------------------------------------
31-
TOTAL 445 31 0
31+
TOTAL 456 20 0

t/results/draft2020-12-acceptance-format.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ date.json 47 0 0
1212
duration.json 26 0 0
1313
ecmascript-regex.json 0 1 0
1414
email.json 20 2 0
15-
hostname.json 20 5 0
15+
hostname.json 25 0 0
1616
idn-email.json 10 0 0
17-
idn-hostname.json 37 21 0
17+
idn-hostname.json 43 15 0
1818
ipv4.json 16 0 0
1919
ipv6.json 40 0 0
2020
iri-reference.json 11 2 0
@@ -29,4 +29,4 @@ uri-template.json 9 1 0
2929
uri.json 25 1 0
3030
uuid.json 21 0 0
3131
---------------------------------------------------------------
32-
TOTAL 450 34 0
32+
TOTAL 461 23 0

t/results/draft4-acceptance-format.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ filename pass todo-fail fail
99
---------------------------------------------------------------
1010
date-time.json 25 0 0
1111
email.json 15 0 0
12-
hostname.json 20 4 0
12+
hostname.json 24 0 0
1313
ipv4.json 16 0 0
1414
ipv6.json 40 0 0
1515
unknown.json 7 0 0
1616
uri.json 25 1 0
1717
---------------------------------------------------------------
18-
TOTAL 148 5 0
18+
TOTAL 152 1 0

t/results/draft6-acceptance-format.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ filename pass todo-fail fail
99
---------------------------------------------------------------
1010
date-time.json 25 0 0
1111
email.json 15 0 0
12-
hostname.json 20 4 0
12+
hostname.json 24 0 0
1313
ipv4.json 16 0 0
1414
ipv6.json 40 0 0
1515
json-pointer.json 38 0 0
@@ -18,4 +18,4 @@ uri-reference.json 13 0 0
1818
uri-template.json 9 1 0
1919
uri.json 25 1 0
2020
---------------------------------------------------------------
21-
TOTAL 208 6 0
21+
TOTAL 212 2 0

t/results/draft7-acceptance-format.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ filename pass todo-fail fail
1010
date-time.json 25 0 0
1111
date.json 47 0 0
1212
email.json 15 0 0
13-
hostname.json 20 4 0
13+
hostname.json 24 0 0
1414
idn-email.json 10 0 0
15-
idn-hostname.json 37 20 0
15+
idn-hostname.json 42 15 0
1616
ipv4.json 16 0 0
1717
ipv6.json 40 0 0
1818
iri-reference.json 11 2 0
@@ -26,4 +26,4 @@ uri-reference.json 13 0 0
2626
uri-template.json 9 1 0
2727
uri.json 25 1 0
2828
---------------------------------------------------------------
29-
TOTAL 398 29 0
29+
TOTAL 407 20 0

t/zzz-acceptance-draft2019-09-format.t

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,10 @@ acceptance_tests(
6868
!$ENV{AUTHOR_TESTING} && !eval { require Net::IDN::Encode; 1 } ? 'idn-hostname.json' : (),
6969
] },
7070
# various edge cases that are difficult to accomodate
71-
{ file => 'hostname.json', test_description => [
72-
'single label with hyphen',
73-
'single label with digits',
74-
'single label starting with digit',
75-
'single label ending with digit',
76-
'single label',
77-
] },
7871
{ file => 'iri.json', group_description => 'validation of IRIs', # see test suite issue 395
7972
test_description => 'an invalid IRI based on IPv6' },
8073
{ file => 'idn-hostname.json',
8174
group_description => 'validation of internationalized host names' }, # IDN decoder, Data::Validate::Domain both have issues
82-
{ file => 'idn-hostname.json',
83-
group_description => 'validation of separators in internationalized host names',
84-
test_description => [
85-
'dot as label separator',
86-
'ideographic full stop as label separator',
87-
'fullwidth full stop as label separator',
88-
'halfwidth ideographic full stop as label separator',
89-
] },
9075
{ file => 'uri.json',
9176
test_description => 'validation of URIs',
9277
test_description => 'an invalid URI with comma in scheme' }, # Mojo::URL does not fully validate

t/zzz-acceptance-draft2020-12-format.t

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,10 @@ acceptance_tests(
6969
] },
7070
# various edge cases that are difficult to accomodate
7171
{ file => 'email.json', group_description => 'validation of e-mail addresses', test_description => [ 'an invalid domain', 'an invalid IPv4-address-literal' ] },
72-
{ file => 'hostname.json', test_description => [
73-
'single label with hyphen',
74-
'single label with digits',
75-
'single label starting with digit',
76-
'single label ending with digit',
77-
'single label',
78-
] },
7972
{ file => 'iri.json', group_description => 'validation of IRIs', # see test suite issue 395
8073
test_description => 'an invalid IRI based on IPv6' },
8174
{ file => 'idn-hostname.json',
8275
group_description => 'validation of internationalized host names' }, # IDN decoder, Data::Validate::Domain both have issues
83-
{ file => 'idn-hostname.json',
84-
group_description => 'validation of separators in internationalized host names',
85-
test_description => [
86-
'dot as label separator',
87-
'ideographic full stop as label separator',
88-
'fullwidth full stop as label separator',
89-
'halfwidth ideographic full stop as label separator',
90-
] },
9176
{ file => 'uri.json',
9277
test_description => 'validation of URIs',
9378
test_description => 'an invalid URI with comma in scheme' }, # Mojo::URL does not fully validate

t/zzz-acceptance-draft4-format.t

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ acceptance_tests(
6565
!$ENV{AUTHOR_TESTING} && !eval { require Data::Validate::Domain; 1 } ? 'hostname.json' : (),
6666
] },
6767
# various edge cases that are difficult to accomodate
68-
{ file => 'hostname.json', test_description => [
69-
'single label with hyphen',
70-
'single label with digits',
71-
'single label ending with digit',
72-
'single label',
73-
] },
7468
{ file => 'uri.json',
7569
test_description => 'validation of URIs',
7670
test_description => 'an invalid URI with comma in scheme' }, # Mojo::URL does not fully validate

0 commit comments

Comments
 (0)