Skip to content

Commit dd1cd33

Browse files
committed
Merge commit 'd1b69fc7c69fca9f04cfdd3ee3b1f156fc97a5f1'
* commit 'd1b69fc7c69fca9f04cfdd3ee3b1f156fc97a5f1': Squashed 'json/' changes from e524505b..83e866b4
2 parents 850befe + d1b69fc commit dd1cd33

File tree

10 files changed

+449
-9
lines changed

10 files changed

+449
-9
lines changed

json/bin/annotate-specification-links

+29-4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ def line_number_of(path: Path, case: dict[str, Any]) -> int:
6161
1,
6262
)
6363

64+
def extract_kind_and_spec(key: str) -> (str, str):
65+
"""
66+
Extracts specification number and kind from the defined key
67+
"""
68+
can_have_spec = ["rfc", "iso"]
69+
if not any(key.startswith(el) for el in can_have_spec):
70+
return key, ""
71+
number = re.search(r"\d+", key)
72+
spec = "" if number is None else number.group(0)
73+
kind = key.removesuffix(spec)
74+
return kind, spec
75+
6476

6577
def main():
6678
# Clear annotations which may have been emitted by a previous run.
@@ -82,20 +94,33 @@ def main():
8294
line=error.lineno,
8395
col=error.pos + 1,
8496
title=str(error),
97+
message=f"cannot load {path}"
8598
)
8699
sys.stdout.write(error)
100+
continue
87101

88102
for test_case in contents:
89103
specifications = test_case.get("specification")
90104
if specifications is not None:
91105
for each in specifications:
92106
quote = each.pop("quote", "")
93-
(kind, section), = each.items()
107+
(key, section), = each.items()
94108

95-
number = re.search(r"\d+", kind)
96-
spec = "" if number is None else number.group(0)
109+
(kind, spec) = extract_kind_and_spec(key)
110+
111+
url_template = version_urls[kind]
112+
if url_template is None:
113+
error = annotation(
114+
level="error",
115+
path=path,
116+
line=line_number_of(path, test_case),
117+
title=f"unsupported template '{kind}'",
118+
message=f"cannot find a URL template for '{kind}'"
119+
)
120+
sys.stdout.write(error)
121+
continue
97122

98-
url = version_urls[kind].expand(
123+
url = url_template.expand(
99124
spec=spec,
100125
section=section,
101126
)

json/bin/specification_urls.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"external": {
2929
"ecma262": "https://262.ecma-international.org/{section}",
3030
"perl5": "https://perldoc.perl.org/perlre#{section}",
31-
"rfc": "https://www.rfc-editor.org/rfc/{spec}.txt#{section}",
31+
"rfc": "https://www.rfc-editor.org/rfc/rfc{spec}.html#section-{section}",
3232
"iso": "https://www.iso.org/obp/ui"
3333
}
3434
}

json/tests/draft-next/optional/format/idn-hostname.json

+48-1
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,58 @@
331331
"description": "empty string",
332332
"data": "",
333333
"valid": false
334-
},
334+
}
335+
]
336+
},
337+
{
338+
"description": "validation of separators in internationalized host names",
339+
"specification": [
340+
{"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"}
341+
],
342+
"schema": {
343+
"$schema": "https://json-schema.org/draft/next/schema",
344+
"format": "idn-hostname"
345+
},
346+
"tests": [
335347
{
336348
"description": "single dot",
337349
"data": ".",
338350
"valid": false
351+
},
352+
{
353+
"description": "single ideographic full stop",
354+
"data": "\u3002",
355+
"valid": false
356+
},
357+
{
358+
"description": "single fullwidth full stop",
359+
"data": "\uff0e",
360+
"valid": false
361+
},
362+
{
363+
"description": "single halfwidth ideographic full stop",
364+
"data": "\uff61",
365+
"valid": false
366+
},
367+
{
368+
"description": "dot as label separator",
369+
"data": "a.b",
370+
"valid": true
371+
},
372+
{
373+
"description": "ideographic full stop as label separator",
374+
"data": "a\u3002b",
375+
"valid": true
376+
},
377+
{
378+
"description": "fullwidth full stop as label separator",
379+
"data": "a\uff0eb",
380+
"valid": true
381+
},
382+
{
383+
"description": "halfwidth ideographic full stop as label separator",
384+
"data": "a\uff61b",
385+
"valid": true
339386
}
340387
]
341388
}

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

+48-1
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,58 @@
331331
"description": "empty string",
332332
"data": "",
333333
"valid": false
334-
},
334+
}
335+
]
336+
},
337+
{
338+
"description": "validation of separators in internationalized host names",
339+
"specification": [
340+
{"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"}
341+
],
342+
"schema": {
343+
"$schema": "https://json-schema.org/draft/2019-09/schema",
344+
"format": "idn-hostname"
345+
},
346+
"tests": [
335347
{
336348
"description": "single dot",
337349
"data": ".",
338350
"valid": false
351+
},
352+
{
353+
"description": "single ideographic full stop",
354+
"data": "\u3002",
355+
"valid": false
356+
},
357+
{
358+
"description": "single fullwidth full stop",
359+
"data": "\uff0e",
360+
"valid": false
361+
},
362+
{
363+
"description": "single halfwidth ideographic full stop",
364+
"data": "\uff61",
365+
"valid": false
366+
},
367+
{
368+
"description": "dot as label separator",
369+
"data": "a.b",
370+
"valid": true
371+
},
372+
{
373+
"description": "ideographic full stop as label separator",
374+
"data": "a\u3002b",
375+
"valid": true
376+
},
377+
{
378+
"description": "fullwidth full stop as label separator",
379+
"data": "a\uff0eb",
380+
"valid": true
381+
},
382+
{
383+
"description": "halfwidth ideographic full stop as label separator",
384+
"data": "a\uff61b",
385+
"valid": true
339386
}
340387
]
341388
}

json/tests/draft2019-09/propertyNames.json

+53
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,58 @@
111111
"valid": true
112112
}
113113
]
114+
},
115+
{
116+
"description": "propertyNames with const",
117+
"schema": {
118+
"$schema": "https://json-schema.org/draft/2019-09/schema",
119+
"propertyNames": {"const": "foo"}
120+
},
121+
"tests": [
122+
{
123+
"description": "object with property foo is valid",
124+
"data": {"foo": 1},
125+
"valid": true
126+
},
127+
{
128+
"description": "object with any other property is invalid",
129+
"data": {"bar": 1},
130+
"valid": false
131+
},
132+
{
133+
"description": "empty object is valid",
134+
"data": {},
135+
"valid": true
136+
}
137+
]
138+
},
139+
{
140+
"description": "propertyNames with enum",
141+
"schema": {
142+
"$schema": "https://json-schema.org/draft/2019-09/schema",
143+
"propertyNames": {"enum": ["foo", "bar"]}
144+
},
145+
"tests": [
146+
{
147+
"description": "object with property foo is valid",
148+
"data": {"foo": 1},
149+
"valid": true
150+
},
151+
{
152+
"description": "object with property foo and bar is valid",
153+
"data": {"foo": 1, "bar": 1},
154+
"valid": true
155+
},
156+
{
157+
"description": "object with any other property is invalid",
158+
"data": {"baz": 1},
159+
"valid": false
160+
},
161+
{
162+
"description": "empty object is valid",
163+
"data": {},
164+
"valid": true
165+
}
166+
]
114167
}
115168
]

json/tests/draft2020-12/optional/format/idn-hostname.json

+48-1
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,58 @@
331331
"description": "empty string",
332332
"data": "",
333333
"valid": false
334-
},
334+
}
335+
]
336+
},
337+
{
338+
"description": "validation of separators in internationalized host names",
339+
"specification": [
340+
{"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"}
341+
],
342+
"schema": {
343+
"$schema": "https://json-schema.org/draft/2020-12/schema",
344+
"format": "idn-hostname"
345+
},
346+
"tests": [
335347
{
336348
"description": "single dot",
337349
"data": ".",
338350
"valid": false
351+
},
352+
{
353+
"description": "single ideographic full stop",
354+
"data": "\u3002",
355+
"valid": false
356+
},
357+
{
358+
"description": "single fullwidth full stop",
359+
"data": "\uff0e",
360+
"valid": false
361+
},
362+
{
363+
"description": "single halfwidth ideographic full stop",
364+
"data": "\uff61",
365+
"valid": false
366+
},
367+
{
368+
"description": "dot as label separator",
369+
"data": "a.b",
370+
"valid": true
371+
},
372+
{
373+
"description": "ideographic full stop as label separator",
374+
"data": "a\u3002b",
375+
"valid": true
376+
},
377+
{
378+
"description": "fullwidth full stop as label separator",
379+
"data": "a\uff0eb",
380+
"valid": true
381+
},
382+
{
383+
"description": "halfwidth ideographic full stop as label separator",
384+
"data": "a\uff61b",
385+
"valid": true
339386
}
340387
]
341388
}

0 commit comments

Comments
 (0)