teptris 0.3.19.1-s390x-linux → 0.3.21.0-s390x-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Steepfile +1 -0
- data/ext/teptris_ext/engine/README.md +1 -1
- data/ext/teptris_ext/engine/src/include/teptris/schema.h +107 -0
- data/ext/teptris_ext/engine/src/include/teptris/version.h +2 -2
- data/ext/teptris_ext/engine/src/teptris/schema/formats.c +656 -0
- data/ext/teptris_ext/engine/src/teptris/schema/json_read.c +440 -0
- data/ext/teptris_ext/engine/src/teptris/schema/json_read.h +34 -0
- data/ext/teptris_ext/engine/src/teptris/schema/regex.c +1090 -0
- data/ext/teptris_ext/engine/src/teptris/schema/regex.h +25 -0
- data/ext/teptris_ext/engine/src/teptris/schema/schema.c +734 -0
- data/ext/teptris_ext/engine/src/teptris/schema/schema_internal.h +221 -0
- data/ext/teptris_ext/engine/src/teptris/schema/validate.c +1034 -0
- data/ext/teptris_ext/materialize.c +87 -1
- data/lib/teptris/3.3/teptris_ext.so +0 -0
- data/lib/teptris/3.4/teptris_ext.so +0 -0
- data/lib/teptris/4.0/teptris_ext.so +0 -0
- data/lib/teptris/schema.rb +64 -0
- data/lib/teptris/version.rb +1 -1
- data/lib/teptris.rb +1 -0
- data/sig/teptris.rbs +32 -0
- metadata +12 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17ec0f95aea55f059c73e75ad48e438fb81b93836d9e8cb347feec988bffe6bc
|
|
4
|
+
data.tar.gz: b9598848b973a38b76a2c3dc855b72b73a090931fa3dc5b9b7b4b6027159f916
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54c18aa7eb23ff3f035742456bde7e9393678c1d73ab9f5316f0cc712ef4f140b837219aa38cb48c1453cc934c148545834c6ca414029612f517f83992a47482
|
|
7
|
+
data.tar.gz: 48061bbc920da9f87403ca858b04d6055ccbd867669d2b8312d38f62d9cecb664dbf9aa821ab4651df365dcc4dc0ae8d44ecfa39a4645dbde3b15e976a5bb452
|
data/Steepfile
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#ifndef TEPTRIS_SCHEMA_H
|
|
2
|
+
#define TEPTRIS_SCHEMA_H
|
|
3
|
+
|
|
4
|
+
/* JSON Schema validation for TOML documents (draft 2020-12, practical
|
|
5
|
+
* subset). Compile a schema once, validate many documents. One
|
|
6
|
+
* implementation, every runtime.
|
|
7
|
+
*
|
|
8
|
+
* ------------------------------------------------------------- policies --
|
|
9
|
+
* TOML and JSON differ in exactly four places; each difference has a
|
|
10
|
+
* documented policy:
|
|
11
|
+
*
|
|
12
|
+
* 1. null. TOML has no null. A schema branch requiring null (a bare
|
|
13
|
+
* `"type": "null"`, or an enum/const entry of null) matches no TOML
|
|
14
|
+
* value. Optionality stays with `required` + absence, so the common
|
|
15
|
+
* JSON idiom `"type": ["string", "null"]` behaves as an optional
|
|
16
|
+
* string: absent passes, a present string passes, any other present
|
|
17
|
+
* value fails. No special-casing: null-typed branches simply never
|
|
18
|
+
* match.
|
|
19
|
+
*
|
|
20
|
+
* 2. integer. TOML's integer is a DISTINCT type from float (`1` and
|
|
21
|
+
* `1.0` differ). `"type": "integer"` matches only TOML integers - a
|
|
22
|
+
* float never validates as integer, even with zero fractional part.
|
|
23
|
+
* `"type": "number"` matches both.
|
|
24
|
+
*
|
|
25
|
+
* 3. datetimes. TOML's four datetime shapes validate as `type:
|
|
26
|
+
* "string"` (their JSON view), and the `format` keywords
|
|
27
|
+
* "date-time", "date" and "time" check the datetime SHAPE: a TOML
|
|
28
|
+
* datetime value of the matching shape passes, and so does a string
|
|
29
|
+
* whose content parses as that shape. Other formats are annotations
|
|
30
|
+
* (checked by the host, if at all) - draft 2020-12 makes format
|
|
31
|
+
* annotation-only by default.
|
|
32
|
+
*
|
|
33
|
+
* 4. non-finite floats. `nan`, `inf`, `-inf` are TOML floats: they
|
|
34
|
+
* match `type: "number"`. nan compares false against everything,
|
|
35
|
+
* so it fails every range/multipleOf constraint; inf violates any
|
|
36
|
+
* `maximum`. No special-casing.
|
|
37
|
+
*
|
|
38
|
+
* ---------------------------------------------------------- semantics --
|
|
39
|
+
* - `$ref` resolves local JSON Pointers ("#/...", "#", plain-name
|
|
40
|
+
* "#anchor" via `$anchor`), including recursive definitions. Remote
|
|
41
|
+
* references (absolute URIs) are REJECTED at compile: a parser
|
|
42
|
+
* library never touches the network.
|
|
43
|
+
* - Keywords that would silently change validation results when
|
|
44
|
+
* ignored (`unevaluatedProperties`, `unevaluatedItems`,
|
|
45
|
+
* `$dynamicRef`, `$dynamicAnchor`, `$recursiveRef`, `$recursiveAnchor`,
|
|
46
|
+
* backreferences / lookahead / lookbehind in patterns) are REJECTED
|
|
47
|
+
* at compile with a diagnostic. Unknown keywords are ignored (they
|
|
48
|
+
* are extensions per the spec).
|
|
49
|
+
* - Patterns run on a linear-time NFA (Thompson construction): immune
|
|
50
|
+
* to ReDoS by construction. Practical ECMA subset: literals, '.',
|
|
51
|
+
* classes, groups, alternation, greedy quantifiers, anchors, \b,
|
|
52
|
+
* \d \w \s (and negations), \xNN, \uNNNN. Lazy quantifiers are
|
|
53
|
+
* accepted (boolean match semantics are identical).
|
|
54
|
+
* - Validation collects every error it finds, up to 256, and reports
|
|
55
|
+
* them as a JSON array of {"path", "schemaPath", "message"}; an
|
|
56
|
+
* empty array means the document is valid. Paths are dotted TOML
|
|
57
|
+
* paths with array indices ("items.0.name"); keys containing a dot
|
|
58
|
+
* are quoted ("\"my.key\"").
|
|
59
|
+
*
|
|
60
|
+
* Memory: every buffer handed out (*buf, *diag_buf) is malloc'd; the
|
|
61
|
+
* caller frees it with free(). */
|
|
62
|
+
#include <stddef.h>
|
|
63
|
+
|
|
64
|
+
#include "teptris/teptris.h"
|
|
65
|
+
|
|
66
|
+
#ifdef __cplusplus
|
|
67
|
+
extern "C" {
|
|
68
|
+
#endif
|
|
69
|
+
|
|
70
|
+
typedef struct teptris_schema teptris_schema;
|
|
71
|
+
|
|
72
|
+
/* Compile a schema from JSON text. On failure *out stays unset and
|
|
73
|
+
* *diag_buf (if non-NULL) receives a malloc'd JSON diagnostic
|
|
74
|
+
* {"error": "...", "path": "..."} locating the problem; free it with
|
|
75
|
+
* teptris_diag_free. Either out or diag_buf may be NULL if the caller
|
|
76
|
+
* does not want it. */
|
|
77
|
+
TEPTRIS_API teptris_status teptris_schema_compile(const char *json, size_t len,
|
|
78
|
+
teptris_schema **out,
|
|
79
|
+
char **diag_buf,
|
|
80
|
+
size_t *diag_len);
|
|
81
|
+
|
|
82
|
+
/* Free a compile diagnostic. */
|
|
83
|
+
TEPTRIS_API void teptris_diag_free(char *buf);
|
|
84
|
+
|
|
85
|
+
/* Validate a parsed document against the schema. *buf receives a
|
|
86
|
+
* malloc'd JSON array of error objects (empty array = valid); free it
|
|
87
|
+
* with free(). At most 256 errors are collected. */
|
|
88
|
+
TEPTRIS_API teptris_status teptris_schema_validate_doc(
|
|
89
|
+
const teptris_schema *sch, const teptris_document *doc, char **buf,
|
|
90
|
+
size_t *out_len);
|
|
91
|
+
|
|
92
|
+
/* Parse TOML text and validate it. A malformed document returns
|
|
93
|
+
* TEPTRIS_ERR_SYNTAX (with *out unchanged - parse it separately with
|
|
94
|
+
* teptris_parse to read the position). */
|
|
95
|
+
TEPTRIS_API teptris_status teptris_schema_validate(const teptris_schema *sch,
|
|
96
|
+
const char *toml, size_t len,
|
|
97
|
+
char **buf, size_t *out_len);
|
|
98
|
+
|
|
99
|
+
/* Free a compiled schema. Compiled schemas are independent of any
|
|
100
|
+
* document; reuse across documents is the intended pattern. */
|
|
101
|
+
TEPTRIS_API void teptris_schema_free(teptris_schema *sch);
|
|
102
|
+
|
|
103
|
+
#ifdef __cplusplus
|
|
104
|
+
}
|
|
105
|
+
#endif
|
|
106
|
+
|
|
107
|
+
#endif /* TEPTRIS_SCHEMA_H */
|