Skip to content

Commit 8fd4fce

Browse files
authored
Merge pull request #786 from jdesrosiers/a-label-tests
Add more comprehensive tessts for A-labels in the "hostname" format
2 parents be58fa9 + b8bb858 commit 8fd4fce

File tree

4 files changed

+984
-142
lines changed

4 files changed

+984
-142
lines changed

tests/draft2019-09/optional/format/hostname.json

Lines changed: 246 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,55 @@
4242
"valid": true
4343
},
4444
{
45-
"description": "a valid punycoded IDN hostname",
46-
"data": "xn--4gbwdl.xn--wgbh1c",
45+
"description": "single label",
46+
"data": "hostname",
47+
"valid": true
48+
},
49+
{
50+
"description": "single label with digits",
51+
"data": "h0stn4me",
4752
"valid": true
4853
},
4954
{
50-
"description": "a host name starting with an illegal character",
51-
"data": "-a-host-name-that-starts-with--",
55+
"description": "single label starting with digit",
56+
"data": "1host",
57+
"valid": true
58+
},
59+
{
60+
"description": "single label ending with digit",
61+
"data": "hostnam3",
62+
"valid": true
63+
},
64+
{
65+
"description": "empty string",
66+
"data": "",
67+
"valid": false
68+
},
69+
{
70+
"description": "single dot",
71+
"data": ".",
5272
"valid": false
5373
},
5474
{
55-
"description": "a host name containing illegal characters",
56-
"data": "not_a_valid_host_name",
75+
"description": "leading dot",
76+
"data": ".example",
5777
"valid": false
5878
},
5979
{
60-
"description": "a host name with a component too long",
61-
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
80+
"description": "trailing dot",
81+
"data": "example.",
6282
"valid": false
6383
},
84+
{
85+
"description": "IDN label separator",
86+
"data": "example\uff0ecom",
87+
"valid": false
88+
},
89+
{
90+
"description": "single label with hyphen",
91+
"data": "host-name",
92+
"valid": true
93+
},
6494
{
6595
"description": "starts with hyphen",
6696
"data": "-hostname",
@@ -72,79 +102,259 @@
72102
"valid": false
73103
},
74104
{
75-
"description": "starts with underscore",
76-
"data": "_hostname",
105+
"description": "contains \"--\" in the 3rd and 4th position",
106+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
107+
"data": "XN--aa---o47jg78q",
77108
"valid": false
78109
},
79110
{
80-
"description": "ends with underscore",
81-
"data": "hostname_",
111+
"description": "contains underscore",
112+
"data": "host_name",
82113
"valid": false
83114
},
84115
{
85-
"description": "contains underscore",
86-
"data": "host_name",
116+
"description": "exceeds maximum overall length (256)",
117+
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
87118
"valid": false
88119
},
89120
{
90-
"description": "maximum label length",
121+
"description": "maximum label length (63)",
91122
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
92123
"valid": true
93124
},
94125
{
95-
"description": "exceeds maximum label length",
126+
"description": "exceeds maximum label length (63)",
96127
"data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
97128
"valid": false
129+
}
130+
]
131+
},
132+
{
133+
"description": "validation of A-label (punycode) host names",
134+
"schema": {
135+
"$schema": "https://json-schema.org/draft/2019-09/schema",
136+
"format": "hostname"
137+
},
138+
"tests": [
139+
{
140+
"description": "invalid Punycode",
141+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
142+
"data": "xn--X",
143+
"valid": false
98144
},
99145
{
100-
"description": "single label",
101-
"data": "hostname",
146+
"description": "a valid host name (example.test in Hangul)",
147+
"data": "xn--9n2bp8q.xn--9t4b11yi5a",
102148
"valid": true
103149
},
104150
{
105-
"description": "single label with hyphen",
106-
"data": "host-name",
151+
"description": "contains illegal char U+302E Hangul single dot tone mark",
152+
"data": "xn--07jt112bpxg.xn--9t4b11yi5a",
153+
"valid": false
154+
},
155+
{
156+
"description": "Begins with a Spacing Combining Mark",
157+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
158+
"data": "xn--hello-txk",
159+
"valid": false
160+
},
161+
{
162+
"description": "Begins with a Nonspacing Mark",
163+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
164+
"data": "xn--hello-zed",
165+
"valid": false
166+
},
167+
{
168+
"description": "Begins with an Enclosing Mark",
169+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
170+
"data": "xn--hello-6bf",
171+
"valid": false
172+
},
173+
{
174+
"description": "Exceptions that are PVALID, left-to-right chars",
175+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6",
176+
"data": "xn--zca29lwxobi7a",
107177
"valid": true
108178
},
109179
{
110-
"description": "single label with digits",
111-
"data": "h0stn4me",
180+
"description": "Exceptions that are PVALID, right-to-left chars",
181+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6",
182+
"data": "xn--qmbc",
112183
"valid": true
113184
},
114185
{
115-
"description": "single label starting with digit",
116-
"data": "1host",
186+
"description": "Exceptions that are DISALLOWED, right-to-left chars",
187+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6",
188+
"data": "xn--chb89f",
189+
"valid": false
190+
},
191+
{
192+
"description": "Exceptions that are DISALLOWED, left-to-right chars",
193+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6 Note: The two combining marks (U+302E and U+302F) are in the middle and not at the start",
194+
"data": "xn--07jceefgh4c",
195+
"valid": false
196+
},
197+
{
198+
"description": "MIDDLE DOT with no preceding 'l'",
199+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
200+
"data": "xn--al-0ea",
201+
"valid": false
202+
},
203+
{
204+
"description": "MIDDLE DOT with nothing preceding",
205+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
206+
"data": "xn--l-fda",
207+
"valid": false
208+
},
209+
{
210+
"description": "MIDDLE DOT with no following 'l'",
211+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
212+
"data": "xn--la-0ea",
213+
"valid": false
214+
},
215+
{
216+
"description": "MIDDLE DOT with nothing following",
217+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
218+
"data": "xn--l-gda",
219+
"valid": false
220+
},
221+
{
222+
"description": "MIDDLE DOT with surrounding 'l's",
223+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3",
224+
"data": "xn--ll-0ea",
117225
"valid": true
118226
},
119227
{
120-
"description": "single label ending with digit",
121-
"data": "hostnam3",
228+
"description": "Greek KERAIA not followed by Greek",
229+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4",
230+
"data": "xn--S-jib3p",
231+
"valid": false
232+
},
233+
{
234+
"description": "Greek KERAIA not followed by anything",
235+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4",
236+
"data": "xn--wva3j",
237+
"valid": false
238+
},
239+
{
240+
"description": "Greek KERAIA followed by Greek",
241+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4",
242+
"data": "xn--wva3je",
122243
"valid": true
123244
},
124245
{
125-
"description": "empty string",
126-
"data": "",
246+
"description": "Hebrew GERESH not preceded by Hebrew",
247+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5",
248+
"data": "xn--A-2hc5h",
127249
"valid": false
128250
},
129251
{
130-
"description": "single dot",
131-
"data": ".",
252+
"description": "Hebrew GERESH not preceded by anything",
253+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5",
254+
"data": "xn--5db1e",
132255
"valid": false
133256
},
134257
{
135-
"description": "leading dot",
136-
"data": ".example",
258+
"description": "Hebrew GERESH preceded by Hebrew",
259+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5",
260+
"data": "xn--4dbc5h",
261+
"valid": true
262+
},
263+
{
264+
"description": "Hebrew GERSHAYIM not preceded by Hebrew",
265+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6",
266+
"data": "xn--A-2hc8h",
137267
"valid": false
138268
},
139269
{
140-
"description": "trailing dot",
141-
"data": "example.",
270+
"description": "Hebrew GERSHAYIM not preceded by anything",
271+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6",
272+
"data": "xn--5db3e",
142273
"valid": false
143274
},
144275
{
145-
"description": "IDN label separator",
146-
"data": "example\uff0ecom",
276+
"description": "Hebrew GERSHAYIM preceded by Hebrew",
277+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6",
278+
"data": "xn--4dbc8h",
279+
"valid": true
280+
},
281+
{
282+
"description": "KATAKANA MIDDLE DOT with no Hiragana, Katakana, or Han",
283+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7",
284+
"data": "xn--defabc-k64e",
147285
"valid": false
286+
},
287+
{
288+
"description": "KATAKANA MIDDLE DOT with no other characters",
289+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7",
290+
"data": "xn--vek",
291+
"valid": false
292+
},
293+
{
294+
"description": "KATAKANA MIDDLE DOT with Hiragana",
295+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7",
296+
"data": "xn--k8j5u",
297+
"valid": true
298+
},
299+
{
300+
"description": "KATAKANA MIDDLE DOT with Katakana",
301+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7",
302+
"data": "xn--bck0j",
303+
"valid": true
304+
},
305+
{
306+
"description": "KATAKANA MIDDLE DOT with Han",
307+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7",
308+
"data": "xn--vek778f",
309+
"valid": true
310+
},
311+
{
312+
"description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits",
313+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8",
314+
"data": "xn--ngb6iyr",
315+
"valid": false
316+
},
317+
{
318+
"description": "Arabic-Indic digits not mixed with Extended Arabic-Indic digits",
319+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8",
320+
"data": "xn--ngba1o",
321+
"valid": true
322+
},
323+
{
324+
"description": "Extended Arabic-Indic digits not mixed with Arabic-Indic digits",
325+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.9",
326+
"data": "xn--0-gyc",
327+
"valid": true
328+
},
329+
{
330+
"description": "ZERO WIDTH JOINER not preceded by Virama",
331+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf",
332+
"data": "xn--11b2er09f",
333+
"valid": false
334+
},
335+
{
336+
"description": "ZERO WIDTH JOINER not preceded by anything",
337+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf",
338+
"data": "xn--02b508i",
339+
"valid": false
340+
},
341+
{
342+
"description": "ZERO WIDTH JOINER preceded by Virama",
343+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf",
344+
"data": "xn--11b2ezcw70k",
345+
"valid": true
346+
},
347+
{
348+
"description": "ZERO WIDTH NON-JOINER preceded by Virama",
349+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1",
350+
"data": "xn--11b2ezcs70k",
351+
"valid": true
352+
},
353+
{
354+
"description": "ZERO WIDTH NON-JOINER not preceded by Virama but matches regexp",
355+
"comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement",
356+
"data": "xn--ngba5hb2804a",
357+
"valid": true
148358
}
149359
]
150360
}

0 commit comments

Comments
 (0)