yeptris 0.6.56.1-arm-linux-eabihf → 0.6.58.1-arm-linux-eabihf

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/ext/yeptris_native/version.h +2 -2
  3. data/lib/yeptris/3.4/native.so +0 -0
  4. data/lib/yeptris/psych/visitors.rb +123 -20
  5. data/lib/yeptris/psych.rb +91 -15
  6. data/lib/yeptris/yaml.rb +92 -3
  7. data/lib/yeptris.rb +1 -1
  8. data/libyeptris.so +0 -0
  9. data/vendor/libyeptris/CMakeLists.txt +1 -1
  10. data/vendor/libyeptris/src/CMakeLists.txt +5 -0
  11. data/vendor/libyeptris/src/include/yeptris/error.h +2 -1
  12. data/vendor/libyeptris/src/include/yeptris/events.h +7 -0
  13. data/vendor/libyeptris/src/include/yeptris/resolve.h +3 -1
  14. data/vendor/libyeptris/src/include/yeptris/validate.h +157 -0
  15. data/vendor/libyeptris/src/include/yeptris.h +1 -0
  16. data/vendor/libyeptris/src/yeptris/dom/dom.c +56 -20
  17. data/vendor/libyeptris/src/yeptris/dom/dom.h +5 -0
  18. data/vendor/libyeptris/src/yeptris/events/iterparse.c +97 -7
  19. data/vendor/libyeptris/src/yeptris/events/pull.c +25 -5
  20. data/vendor/libyeptris/src/yeptris/events/push.c +23 -1
  21. data/vendor/libyeptris/src/yeptris/events/recorder.c +33 -6
  22. data/vendor/libyeptris/src/yeptris/memory/arena.c +9 -1
  23. data/vendor/libyeptris/src/yeptris/memory/pool.c +5 -1
  24. data/vendor/libyeptris/src/yeptris/parse/engine.c +59 -0
  25. data/vendor/libyeptris/src/yeptris/parse.c +22 -8
  26. data/vendor/libyeptris/src/yeptris/resolve/json12.c +103 -0
  27. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +9 -0
  28. data/vendor/libyeptris/src/yeptris/validate/internal.h +102 -0
  29. data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1022 -0
  30. data/vendor/libyeptris/src/yeptris/validate/regexp.c +972 -0
  31. data/vendor/libyeptris/src/yeptris/validate/validate.c +939 -0
  32. metadata +7 -1
@@ -4798,8 +4798,40 @@ typedef struct yep_stepstate {
4798
4798
  * state the whole-stream walk holds at the ---
4799
4799
  * cut, so per-document normalization is
4800
4800
  * byte-identical to the one-buffer walk */
4801
+ int gated; /* the encoding front-end ran: BOM decisions
4802
+ * belong to the stream's first bytes, never to
4803
+ * a mid-stream chunk (a later U+FEFF is
4804
+ * content). While 0 the head may still be a
4805
+ * BOM prefix, and scanned is 0 by the same
4806
+ * law -- every hold returns before step_scan. */
4801
4807
  } yep_stepstate;
4802
4808
 
4809
+ /* True when buf[0..len) could still be the PREFIX of a BOM (the rest
4810
+ * arrives with the next chunk): the sniff needs its full width, so a
4811
+ * 1-3-byte head holds the gate instead of reading a mark's bytes as
4812
+ * content. A buffer long enough for the sniff to decide never gets
4813
+ * here. */
4814
+ static int step_bom_prefix(const char* buf, size_t len) {
4815
+ const unsigned char* p = (const unsigned char*)buf;
4816
+ switch (p[0]) {
4817
+ case 0xEF:
4818
+ return len == 1 || (len == 2 && p[1] == 0xBB);
4819
+ case 0xFF:
4820
+ case 0xFE:
4821
+ return len == 1;
4822
+ case 0x00:
4823
+ if (len == 1) {
4824
+ return 1;
4825
+ }
4826
+ if (p[1] != 0x00) {
4827
+ return 0;
4828
+ }
4829
+ return len == 2 || p[2] == 0xFE;
4830
+ default:
4831
+ return 0;
4832
+ }
4833
+ }
4834
+
4803
4835
  static int engine_run_impl(yep_engine* e, const char* buf, size_t len, const yep_sink* sink,
4804
4836
  int emit_start, int emit_end);
4805
4837
 
@@ -5344,6 +5376,33 @@ int yep_engine_step(yep_engine* e, const char* chunk, size_t len, int final, con
5344
5376
  memcpy(st->buf + st->len, chunk, len);
5345
5377
  st->len += len;
5346
5378
  }
5379
+ /* the encoding front-end the one-shot owns (yep_engine_run): the
5380
+ * stepping route (and the recorder riding it) had NONE, so UTF-16
5381
+ * bytes fed through it parsed garbage silently. The gate runs
5382
+ * once, on the stream's first bytes: the UTF-8 BOM strips (a lone
5383
+ * one is an empty stream, not a U+FEFF scalar -- the one-shot's
5384
+ * round-122 law), a UTF-16/32 BOM rejects (chunk-wise transcoding
5385
+ * cannot carry state across feeds: a surrogate pair split by the
5386
+ * chunk boundary has nowhere to live), and an undecided prefix
5387
+ * holds until enough bytes decide it. */
5388
+ if (!st->gated && st->len > 0) {
5389
+ yep_encoding enc = YEP_ENC_UNKNOWN;
5390
+ size_t bom = yep_bom_sniff((const unsigned char*)st->buf, st->len, &enc);
5391
+ if (enc == YEP_ENC_UTF8) {
5392
+ memmove(st->buf, st->buf + bom, st->len - bom);
5393
+ st->len -= bom;
5394
+ st->gated = 1;
5395
+ } else if (enc == YEP_ENC_UTF16LE || enc == YEP_ENC_UTF16BE || enc == YEP_ENC_UTF32LE ||
5396
+ enc == YEP_ENC_UTF32BE) {
5397
+ yep_error_set(&e->err, YEP_ERR_ENCODING, 1, 1, bom,
5398
+ "the chunked route cannot decode UTF-16/32 input");
5399
+ return -1;
5400
+ } else if (st->len >= 4 || !step_bom_prefix(st->buf, st->len)) {
5401
+ st->gated = 1;
5402
+ } else if (!final) {
5403
+ return 0; /* the head may still complete a BOM: hold */
5404
+ }
5405
+ }
5347
5406
  if (!final) {
5348
5407
  size_t cut = step_scan(st);
5349
5408
  if (cut == 0 || cut >= st->len) {
@@ -325,9 +325,13 @@ static YeptrisDocument parse_impl(const char* buf, size_t len, const YeptrisPars
325
325
  engine_enter:
326
326
  eng = yep_engine_create(sys);
327
327
  if (opts != NULL) {
328
+ /* the typing SSOT: the family's resolver (compat11 when asked,
329
+ * json12 for the 12_JSON validation family, core12 otherwise) */
328
330
  yep_engine_set_resolver(eng, opts->schema == YEPTRIS_SCHEMA_11_COMPAT
329
331
  ? yep_resolver_compat11()
330
- : yep_resolver_core12());
332
+ : (opts->schema == YEPTRIS_SCHEMA_12_JSON
333
+ ? yep_resolver_json12()
334
+ : yep_resolver_core12()));
331
335
  if (opts->schema == YEPTRIS_SCHEMA_11_COMPAT) {
332
336
  /* the compat schema is the psych/libyaml surface: its grammar
333
337
  * must accept what libyaml accepts (the flow floor is suite-
@@ -357,9 +361,13 @@ engine_enter:
357
361
  }
358
362
  /* the direct builders resolve with the engine's schema (the typing
359
363
  * SSOT — one resolver decision per scalar, whichever path builds) */
360
- dom->resolver = (opts != NULL && opts->schema == YEPTRIS_SCHEMA_11_COMPAT)
361
- ? yep_resolver_compat11()
362
- : yep_resolver_core12();
364
+ if (opts != NULL && opts->schema == YEPTRIS_SCHEMA_11_COMPAT) {
365
+ dom->resolver = yep_resolver_compat11();
366
+ } else if (opts != NULL && opts->schema == YEPTRIS_SCHEMA_12_JSON) {
367
+ dom->resolver = yep_resolver_json12();
368
+ } else {
369
+ dom->resolver = yep_resolver_core12();
370
+ }
363
371
  /* BEFORE the run: input-slice strings borrow as views (zero copy)
364
372
  * — the document keeps `transcoded` alive for exactly this. Set
365
373
  * after, every scalar was arena-copied (found 2026-09-10). */
@@ -422,6 +430,8 @@ engine_enter:
422
430
  } else if (have_tape && !norm_kept_raw &&
423
431
  ytap_fused_run(&yt, (opts != NULL && opts->schema == YEPTRIS_SCHEMA_11_COMPAT)
424
432
  ? yep_resolver_compat11()
433
+ : (opts != NULL && opts->schema == YEPTRIS_SCHEMA_12_JSON)
434
+ ? yep_resolver_json12()
425
435
  : yep_resolver_core12()) == 0) {
426
436
  /* the fused block runner owned the whole document — the engine
427
437
  * never runs (TODO.restructure/79). Its only cost was the parse
@@ -437,7 +447,12 @@ engine_enter:
437
447
  }
438
448
  if (rc != 0) {
439
449
  const yep_error* ee = yep_engine_error(eng);
440
- yep_err_code code = ee ? ee->code : YEP_ERR_UNEXPECTED;
450
+ /* a CLEAN channel under a failed run means the SINK failed — a
451
+ * builder ran out of memory (the DOM's oom law), the bytes
452
+ * never were a parse error. Mapping it to PARSE let
453
+ * yep_dom_str_put's swallowed OOM surface as a syntax error
454
+ * (the audit's finding: silent doc corruption reads worse). */
455
+ yep_err_code code = (ee && ee->code != YEP_ERR_NONE) ? ee->code : YEP_ERR_MEMORY;
441
456
  if (ee) {
442
457
  yep_error* tls = yep_error_tls();
443
458
  *tls = *ee;
@@ -491,9 +506,8 @@ engine_enter:
491
506
  }
492
507
  yep_mutex_init(&doc->lazy_mu);
493
508
  doc->sys = sys;
494
- doc->schema = (opts != NULL && opts->schema == YEPTRIS_SCHEMA_11_COMPAT)
495
- ? YEPTRIS_SCHEMA_11_COMPAT
496
- : YEPTRIS_SCHEMA_12_CORE;
509
+ doc->schema = (opts != NULL && opts->schema != YEPTRIS_SCHEMA_12_CORE) ? opts->schema
510
+ : YEPTRIS_SCHEMA_12_CORE;
497
511
  doc->transcoded = transcoded;
498
512
  doc->transcoded_len = transcoded_len;
499
513
  doc->input = buf;
@@ -0,0 +1,103 @@
1
+ /* json12.c — the spec 10.2 JSON schema resolver (#882).
2
+ *
3
+ * The productions are the spec 10.2.2 table (1.2.2 erratum kept: the
4
+ * float regex needs NO digits after the dot — "0." is a float):
5
+ * null: null
6
+ * bool: true | false
7
+ * int: -? ( 0 | [1-9] [0-9]* )
8
+ * float: -? ( 0 | [1-9] [0-9]* ) ( \. [0-9]* )? ( [eE] [-+]? [0-9]+ )?
9
+ * * -> Error (the validator's business; the resolver stays str)
10
+ *
11
+ * Deliberately NOT accepted (the core schema's extensions): "True"/
12
+ * "False"/"NULL" casings, "~"/empty nulls, +signs, 0o/0x radix, .inf/
13
+ * .nan, underscores. The example-10.8 Invalid list pins each one.
14
+ *
15
+ * Shape: yep_json12_plain is the ONE classifier — the resolver wraps
16
+ * it, and the validator re-asks it per plain scalar (no second truth
17
+ * table anywhere). Parse never errors here: a scalar outside the
18
+ * productions resolves str so the DOM stays family-neutral; the
19
+ * validation face turns the spec's Error row into diagnostics.
20
+ */
21
+
22
+ #include <stdint.h>
23
+ #include <string.h>
24
+
25
+ #include "resolver.h"
26
+
27
+ /* JSON int: -?(0|[1-9][0-9]*); optionally continues as the float
28
+ * production (the int regex is a prefix of the float one). Returns 1
29
+ * (int), 2 (float), 0 (no production). */
30
+ int yep_json12_plain(const char* p, uint32_t n) {
31
+ if (n == 0) {
32
+ return 0;
33
+ }
34
+ if (n == 4 && memcmp(p, "null", 4) == 0) {
35
+ return 4; /* null */
36
+ }
37
+ if (n == 4 && memcmp(p, "true", 4) == 0) {
38
+ return 3; /* bool */
39
+ }
40
+ if (n == 5 && memcmp(p, "false", 5) == 0) {
41
+ return 3;
42
+ }
43
+ uint32_t i = (p[0] == '-') ? 1 : 0;
44
+ if (i >= n) {
45
+ return 0; /* lone "-" (or empty after the prefix check) */
46
+ }
47
+ /* int part: 0 | [1-9][0-9]* — no +sign, no leading zeros */
48
+ if (p[i] == '0') {
49
+ i++;
50
+ } else if (p[i] >= '1' && p[i] <= '9') {
51
+ i++;
52
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
53
+ i++;
54
+ }
55
+ } else {
56
+ return 0;
57
+ }
58
+ if (i == n) {
59
+ return 1; /* bare int */
60
+ }
61
+ /* float tail: (\.[0-9]*)? ([eE][-+]?[0-9]+)? — at least one of the
62
+ * two must be present (a bare int already returned) */
63
+ int floaty = 0;
64
+ if (p[i] == '.') {
65
+ floaty = 1;
66
+ i++;
67
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
68
+ i++; /* digits optional after the dot (1.2.2 erratum) */
69
+ }
70
+ }
71
+ if (i < n && (p[i] == 'e' || p[i] == 'E')) {
72
+ i++;
73
+ if (i < n && (p[i] == '+' || p[i] == '-')) {
74
+ i++;
75
+ }
76
+ int ed = 0;
77
+ while (i < n && p[i] >= '0' && p[i] <= '9') {
78
+ i++;
79
+ ed = 1;
80
+ }
81
+ if (!ed) {
82
+ return 0; /* exponent sign(s) with no digits */
83
+ }
84
+ floaty = 1;
85
+ }
86
+ return (floaty && i == n) ? 2 : 0;
87
+ }
88
+
89
+ static yep_tag_id json12(void* ctx, const char* p, uint32_t n) {
90
+ (void)ctx;
91
+ return (yep_tag_id)yep_json12_plain(p, n);
92
+ }
93
+
94
+ static yep_tag_id json12_number(void* ctx, int is_float) {
95
+ (void)ctx;
96
+ return is_float ? 2 : 1;
97
+ }
98
+
99
+ static const yep_resolver k_json12 = {json12, json12_number, NULL};
100
+
101
+ const yep_resolver* yep_resolver_json12(void) {
102
+ return &k_json12;
103
+ }
@@ -40,6 +40,15 @@ static inline yep_tag_id yep_resolve_number(const yep_resolver* r, int is_float)
40
40
  const yep_resolver* yep_resolver_core12(void);
41
41
  const yep_resolver* yep_resolver_compat11(void);
42
42
 
43
+ /* The spec 10.2 JSON schema resolver (#882): null/true/false exact,
44
+ * the JSON int and float productions, everything else str. Parse stays
45
+ * lenient — the VALIDATOR flags plain scalars that matched no
46
+ * production (the spec's `*` -> Error row) through the classifier. */
47
+ const yep_resolver* yep_resolver_json12(void);
48
+ /* 1 when the plain span matches a JSON-schema production. The one
49
+ * truth table for the 12_JSON family (validate/ re-asks it). */
50
+ int yep_json12_plain(const char* p, uint32_t n);
51
+
43
52
  /* core tag id <-> canonical URI (tags.c is the identity SSOT). */
44
53
  const char* yep_tag_uri(yep_tag_id id);
45
54
 
@@ -0,0 +1,102 @@
1
+ /* validate/internal.h — the validation face's shared internals (#882).
2
+ *
3
+ * Private to src/yeptris/validate/: the report shape, the diagnostic
4
+ * emitter (path capture + line/col resolution), and the JSON-pointer
5
+ * scratch path. The two walks (validate.c's schema family and
6
+ * jsonschema.c's keyword subset) share only this — MECE keeps the
7
+ * checks themselves in their own TUs.
8
+ */
9
+ #ifndef YEP_VALIDATE_INTERNAL_H
10
+ #define YEP_VALIDATE_INTERNAL_H
11
+
12
+ #include <stdarg.h>
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ #include <yeptris/validate.h>
17
+
18
+ #include "../dom/dom.h"
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+ /* The report cap: a hostile document can carry O(nodes) violations, so
25
+ * the walk stops here and the LIMIT sentinel replaces the last slot. */
26
+ #define YEP_VALIDATE_MAX_DIAGS 256
27
+
28
+ struct yeptris_validate_report {
29
+ yeptris_diagnostic* diags;
30
+ uint32_t count;
31
+ int truncated;
32
+ };
33
+
34
+ typedef struct yep_vctx {
35
+ const yep_dom* dom;
36
+ yeptris_validate_report* rep;
37
+ /* line/col resolution over the node bytes (lazy: built on the
38
+ * first positioned diagnostic; valid documents never pay) */
39
+ const char* input;
40
+ size_t input_len;
41
+ uint32_t* line_off; /* byte offset of every line start */
42
+ uint32_t line_cnt, line_cap;
43
+ /* JSON-pointer path under construction (DFS scratch) */
44
+ char* path;
45
+ size_t path_len, path_cap;
46
+ int depth; /* the walk's nesting guard (never exceeds the DOM's) */
47
+ int oom; /* an allocation failed: stop diagnosing */
48
+ /* JSON Schema trial suppression (anyOf/oneOf/not probes) */
49
+ int suppress;
50
+ int trial_hit;
51
+ int ref_depth; /* consecutive $ref expansions */
52
+ } yep_vctx;
53
+
54
+ /* Offset of a node's first positioned byte (the value span of the node
55
+ * itself, or of its first scalar leaf for collections; UINT32_MAX when
56
+ * everything reachable lives in the arena — line/col unknown). */
57
+ uint32_t yep_validate_node_off(const yep_dom* d, uint32_t id);
58
+
59
+ /* Emits one diagnostic at the current path. line/col resolve from
60
+ * `off` through the lazy line index; 0/0 when unknown. Detail is
61
+ * printf-composed into the bounded slot. Never fails the caller: the
62
+ * report cap turns the last slot into the LIMIT sentinel. */
63
+ void yep_validate_emit(yep_vctx* c, int code, uint32_t off, const char* detail_fmt, ...);
64
+
65
+ /* JSON-pointer path scratch: push an escaped segment / a decimal
66
+ * index, pop to a mark. 0 ok, -1 OOM (ctx.oom set; the walk unwinds). */
67
+ int yep_validate_path_push(yep_vctx* c, const char* seg, size_t seg_len);
68
+ int yep_validate_path_push_index(yep_vctx* c, uint32_t idx);
69
+ void yep_validate_path_pop(yep_vctx* c, size_t mark);
70
+
71
+ /* The bounded ECMA-regex subset behind `pattern` (jsonschema.c):
72
+ * literals, '.', classes, groups, alternation, the greedy/lazy
73
+ * quantifiers, anchors, \d\w\s\D\W\S\b\B and \xHH. Byte-oriented
74
+ * (ASCII classes; UTF-8 literals match byte-wise). A Thompson NFA —
75
+ * O(len * m), no backtracking blowup; patterns over the program
76
+ * budget are invalid. 1 match, 0 no match, -1 invalid pattern. */
77
+ int yep_re_search(const char* pat, uint32_t pat_len, const char* s, uint32_t s_len);
78
+
79
+ /* Canonical scalar tag of a DOM node (explicit tag, then the parse
80
+ * resolver's plain verdict, then str): the value model both walks
81
+ * compare under. */
82
+ uint8_t yep_validate_scalar_tag(const yep_dnode* n);
83
+
84
+ /* Canonical-form hash and equality over DOM subtrees (spec 3.2.1.3:
85
+ * same tag + canonical form; numbers numerically within a tag). The
86
+ * equality may cross documents — the schema's enum/const live in a
87
+ * different DOM than the instance. Depth-bounded. */
88
+ uint64_t yep_validate_node_hash(const yep_dom* d, uint32_t id, int depth);
89
+ int yep_validate_node_equal(const yep_dom* da, uint32_t a, const yep_dom* db, uint32_t b,
90
+ int depth);
91
+
92
+ /* jsonschema.c's driver: applies the schema tree (its own DOM) to
93
+ * every instance document root, emitting into `rep`. Returns 0, -1
94
+ * on OOM. */
95
+ int yep_jsonschema_run(const yep_dom* schema_dom, uint32_t schema_root, const yep_dom* instance_dom,
96
+ const uint32_t* doc_roots, uint32_t doc_count, yeptris_validate_report* rep);
97
+
98
+ #ifdef __cplusplus
99
+ }
100
+ #endif
101
+
102
+ #endif /* YEP_VALIDATE_INTERNAL_H */