yeptris 0.6.58.1-arm-linux-eabihf → 0.6.60.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 (48) 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/document.rb +15 -0
  5. data/lib/yeptris/ffi.rb +112 -0
  6. data/lib/yeptris/psych/visitors.rb +16 -6
  7. data/lib/yeptris/psych.rb +11 -5
  8. data/lib/yeptris/validation.rb +320 -0
  9. data/lib/yeptris/yaml.rb +128 -6
  10. data/lib/yeptris.rb +2 -1
  11. data/libyeptris.so +0 -0
  12. data/vendor/libyeptris/CMakeLists.txt +1 -1
  13. data/vendor/libyeptris/src/CMakeLists.txt +8 -0
  14. data/vendor/libyeptris/src/include/yeptris/emit.h +30 -2
  15. data/vendor/libyeptris/src/include/yeptris/parse.h +52 -0
  16. data/vendor/libyeptris/src/include/yeptris/resolve.h +8 -0
  17. data/vendor/libyeptris/src/include/yeptris/validate.h +259 -15
  18. data/vendor/libyeptris/src/include/yeptris/values.h +8 -2
  19. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +10 -0
  20. data/vendor/libyeptris/src/yeptris/cbor/decode.c +5 -7
  21. data/vendor/libyeptris/src/yeptris/cbor/encode.c +9 -9
  22. data/vendor/libyeptris/src/yeptris/cbor/from_marshal.c +1 -1
  23. data/vendor/libyeptris/src/yeptris/common/error.h +2 -0
  24. data/vendor/libyeptris/src/yeptris/doc.h +20 -0
  25. data/vendor/libyeptris/src/yeptris/emit/emit.c +85 -13
  26. data/vendor/libyeptris/src/yeptris/emit/writer.c +158 -642
  27. data/vendor/libyeptris/src/yeptris/emit/writer.h +15 -1
  28. data/vendor/libyeptris/src/yeptris/events/push.c +28 -3
  29. data/vendor/libyeptris/src/yeptris/events/values.c +24 -0
  30. data/vendor/libyeptris/src/yeptris/marshal/to_json.c +650 -0
  31. data/vendor/libyeptris/src/yeptris/parse/engine.c +121 -40
  32. data/vendor/libyeptris/src/yeptris/parse/stream_iter.c +326 -0
  33. data/vendor/libyeptris/src/yeptris/parse.c +181 -46
  34. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +1 -1
  35. data/vendor/libyeptris/src/yeptris/resolve/core12.c +11 -3
  36. data/vendor/libyeptris/src/yeptris/resolve/full12.c +201 -0
  37. data/vendor/libyeptris/src/yeptris/resolve/json12.c +12 -6
  38. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +20 -0
  39. data/vendor/libyeptris/src/yeptris/validate/compile.c +306 -0
  40. data/vendor/libyeptris/src/yeptris/validate/internal.h +255 -10
  41. data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1025 -125
  42. data/vendor/libyeptris/src/yeptris/validate/output.c +246 -0
  43. data/vendor/libyeptris/src/yeptris/validate/regexp.c +791 -163
  44. data/vendor/libyeptris/src/yeptris/validate/registry.c +118 -0
  45. data/vendor/libyeptris/src/yeptris/validate/resources.c +601 -0
  46. data/vendor/libyeptris/src/yeptris/validate/stream.c +1155 -0
  47. data/vendor/libyeptris/src/yeptris/validate/validate.c +330 -226
  48. metadata +10 -1
@@ -11,12 +11,22 @@
11
11
  #include "../doc.h"
12
12
  #include "writer.h"
13
13
 
14
+ /* Every field reads behind ITS OWN offsetof gate — never the whole
15
+ * struct's sizeof. The #909/#903 append grew sizeof(*opts) to 24, and
16
+ * a `size >= sizeof(*opts)` gate silently orphaned the ORIGINAL
17
+ * fields for callers compiled against the 16-byte struct (the Ruby
18
+ * binding): best_width fell back to 80 and canonical fell off. The
19
+ * versioning contract is per field: declared-present or default. */
14
20
  static int opts_canonical(const yeptris_emit_options* opts) {
15
- return opts != NULL && opts->size >= sizeof(*opts) && opts->canonical;
21
+ return opts != NULL &&
22
+ opts->size >= (uint32_t)(offsetof(yeptris_emit_options, canonical) + sizeof(int)) &&
23
+ opts->canonical;
16
24
  }
17
25
 
18
26
  static int opts_width(const yeptris_emit_options* opts) {
19
- if (opts == NULL || opts->size < sizeof(*opts) || opts->best_width <= 0) {
27
+ if (opts == NULL ||
28
+ opts->size < (uint32_t)(offsetof(yeptris_emit_options, best_width) + sizeof(int)) ||
29
+ opts->best_width <= 0) {
20
30
  return 80; /* libyaml best_width parity */
21
31
  }
22
32
  return opts->best_width;
@@ -32,6 +42,41 @@ static int opts_doc_marker(const yeptris_emit_options* opts) {
32
42
  return opts->explicit_doc_start != 0;
33
43
  }
34
44
 
45
+ static int opts_indent(const yeptris_emit_options* opts) {
46
+ /* size-versioned (#903); out of range rides the default (libyaml
47
+ * clamps 2..9 the same way) */
48
+ int ind = 2;
49
+ if (opts != NULL &&
50
+ opts->size >= (uint32_t)(offsetof(yeptris_emit_options, best_indent) + sizeof(int))) {
51
+ ind = opts->best_indent;
52
+ }
53
+ if (ind < 2 || ind > 9) {
54
+ ind = 2;
55
+ }
56
+ return ind;
57
+ }
58
+
59
+ static int opts_block_fold(const yeptris_emit_options* opts) {
60
+ /* size-versioned (#903): default off — block output stays
61
+ * width-invariant (byte-identical with the pre-option releases) */
62
+ if (opts == NULL ||
63
+ opts->size < (uint32_t)(offsetof(yeptris_emit_options, block_fold) + sizeof(int))) {
64
+ return 0;
65
+ }
66
+ return opts->block_fold != 0;
67
+ }
68
+
69
+ /* The emitter's SCRATCH rides the document's allocator (#904 item 3):
70
+ * sc_dec and the streaming window are emitter-internal (never leak
71
+ * into caller hands), so the fail-injection harness — a counting
72
+ * allocator passed at the document's build — now reaches them. The
73
+ * CALLER-RETURNED output buffers stay system-malloc on purpose: their
74
+ * release contract is free() (emit.h "malloc'd buffer, caller frees"),
75
+ * and a failing allocator's pointer cannot be freed by the host. */
76
+ static const yep_allocator* emit_sys(const yeptris_document* doc) {
77
+ return doc->sys != NULL ? doc->sys : yep_system_allocator();
78
+ }
79
+
35
80
  YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
36
81
  const yeptris_emit_options* opts, char* buf,
37
82
  size_t cap) {
@@ -62,6 +107,8 @@ YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
62
107
  em.w.json_pretty = 0;
63
108
  em.w.pretty_depth = 0;
64
109
  em.w.best_width = opts_width(opts);
110
+ em.w.indent = opts_indent(opts);
111
+ em.w.block_fold = opts_block_fold(opts);
65
112
  em.w.col = 0;
66
113
  em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
67
114
  em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
@@ -70,10 +117,11 @@ YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
70
117
  em.w.sink_aborted = 0;
71
118
  em.w.flushed = 0;
72
119
  memset(&em.canon_names, 0, sizeof(em.canon_names));
73
- if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
120
+ if (em.w.canonical && !yep_nametab_init(&em.canon_names, emit_sys(em.doc))) {
74
121
  return 0;
75
122
  }
76
- em.w.sc_dec = (uint8_t*)malloc(em.doc->dom->ncount > 0 ? em.doc->dom->ncount : 1);
123
+ em.w.sc_dec =
124
+ (uint8_t*)yep_alloc(emit_sys(em.doc), em.doc->dom->ncount > 0 ? em.doc->dom->ncount : 1);
77
125
  if (em.w.sc_dec == NULL) {
78
126
  if (em.canon_names.sys != NULL) {
79
127
  yep_nametab_free(&em.canon_names);
@@ -82,7 +130,7 @@ YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
82
130
  }
83
131
  size_t need = yep_emit_run(&em, 1);
84
132
  if (buf == NULL || cap < need + 1) {
85
- free(em.w.sc_dec);
133
+ yep_free(emit_sys(em.doc), em.w.sc_dec);
86
134
  if (em.canon_names.sys != NULL) {
87
135
  yep_nametab_free(&em.canon_names);
88
136
  }
@@ -90,7 +138,7 @@ YEPTRIS_API size_t yeptris_serialize_into_ex(YeptrisDocument handle,
90
138
  }
91
139
  em.w.p = buf;
92
140
  size_t wrote = yep_emit_run(&em, 0);
93
- free(em.w.sc_dec);
141
+ yep_free(emit_sys(em.doc), em.w.sc_dec);
94
142
  if (em.canon_names.sys != NULL) {
95
143
  yep_nametab_free(&em.canon_names);
96
144
  }
@@ -128,6 +176,8 @@ YEPTRIS_API size_t yeptris_serialize_into_trusted(YeptrisDocument handle,
128
176
  em.w.json_pretty = 0;
129
177
  em.w.pretty_depth = 0;
130
178
  em.w.best_width = opts_width(opts);
179
+ em.w.indent = opts_indent(opts);
180
+ em.w.block_fold = opts_block_fold(opts);
131
181
  em.w.col = 0;
132
182
  em.w.sv_input = ((const yeptris_document*)handle)->dom->input_base;
133
183
  em.w.sv_arena = ((const yeptris_document*)handle)->dom->str;
@@ -136,7 +186,7 @@ YEPTRIS_API size_t yeptris_serialize_into_trusted(YeptrisDocument handle,
136
186
  em.w.sink_aborted = 0;
137
187
  em.w.flushed = 0;
138
188
  memset(&em.canon_names, 0, sizeof(em.canon_names));
139
- if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
189
+ if (em.w.canonical && !yep_nametab_init(&em.canon_names, emit_sys(em.doc))) {
140
190
  return 0;
141
191
  }
142
192
  /* #352: ONE bounded wet pass — no memo, no dry run (the emit-split
@@ -194,6 +244,8 @@ YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument handle, const yeptris_emi
194
244
  em.w.json_pretty = 0;
195
245
  em.w.pretty_depth = 0;
196
246
  em.w.best_width = opts_width(opts);
247
+ em.w.indent = opts_indent(opts);
248
+ em.w.block_fold = opts_block_fold(opts);
197
249
  em.w.col = 0;
198
250
  em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
199
251
  em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
@@ -202,7 +254,7 @@ YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument handle, const yeptris_emi
202
254
  em.w.sink_aborted = 0;
203
255
  em.w.flushed = 0;
204
256
  memset(&em.canon_names, 0, sizeof(em.canon_names));
205
- if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
257
+ if (em.w.canonical && !yep_nametab_init(&em.canon_names, emit_sys(em.doc))) {
206
258
  return NULL;
207
259
  }
208
260
  /* #352 slice 2: ONE wet pass into a growable buffer — the dry
@@ -211,6 +263,9 @@ YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument handle, const yeptris_emi
211
263
  * starts at the input size (+64) and doubles on demand; a final
212
264
  * shrink-to-fit keeps the returned allocation tight. No dry pass,
213
265
  * so no decisions table. */
266
+ /* raw malloc ON PURPOSE (#904 item 3): this buffer is RETURNED —
267
+ * the release contract is the host's free() (emit.h), so it must
268
+ * come from the system allocator, not the document's */
214
269
  size_t est = em.doc->dom->input_len + 64;
215
270
  if (est < 256) {
216
271
  est = 256;
@@ -260,6 +315,8 @@ YEPTRIS_API char* yeptris_serialize_ex(YeptrisDocument handle, const yeptris_emi
260
315
  * (+64) and doubles on demand; shrink-to-fit at the end. Owns the
261
316
  * emitter's canon_names cleanup. */
262
317
  static char* yep_json_run_growable(yep_emitter* em, size_t* len) {
318
+ /* raw malloc ON PURPOSE (#904 item 3): the buffer is RETURNED —
319
+ * the host's free() owns it (emit.h), system allocator only */
263
320
  size_t est = em->doc->dom->input_len + 64;
264
321
  if (est < 256) {
265
322
  est = 256;
@@ -328,6 +385,8 @@ YEPTRIS_API char* yeptris_serialize_json(YeptrisDocument handle, size_t* len) {
328
385
  em.w.json_pretty = 0;
329
386
  em.w.pretty_depth = 0;
330
387
  em.w.best_width = 0; /* JSON: no folding (single-line output) */
388
+ em.w.indent = 2;
389
+ em.w.block_fold = 0;
331
390
  em.w.col = 0;
332
391
  em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
333
392
  em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
@@ -370,6 +429,8 @@ YEPTRIS_API char* yeptris_serialize_json_ex(YeptrisDocument handle, size_t* len,
370
429
  em.w.json_pretty = 0;
371
430
  em.w.pretty_depth = 0;
372
431
  em.w.best_width = 0; /* JSON: no folding (single-line output) */
432
+ em.w.indent = 2;
433
+ em.w.block_fold = 0;
373
434
  em.w.col = 0;
374
435
  em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
375
436
  em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
@@ -414,6 +475,8 @@ char* yep_serialize_json_compact(const yeptris_document* doc, size_t* len) {
414
475
  em.w.json_pretty = 0;
415
476
  em.w.pretty_depth = 0;
416
477
  em.w.best_width = 0;
478
+ em.w.indent = 2;
479
+ em.w.block_fold = 0;
417
480
  em.w.col = 0;
418
481
  em.w.sv_input = doc->dom->input_base;
419
482
  em.w.sv_arena = doc->dom->str;
@@ -460,6 +523,8 @@ char* yep_serialize_json_pretty_ex(const yeptris_document* doc, size_t* len, con
460
523
  em.w.json_indent = indent;
461
524
  em.w.json_indent_len = indent == NULL ? 2 : (int)indent_len;
462
525
  em.w.best_width = 0;
526
+ em.w.indent = 2;
527
+ em.w.block_fold = 0;
463
528
  em.w.col = 0;
464
529
  em.w.sv_input = doc->dom->input_base;
465
530
  em.w.sv_arena = doc->dom->str;
@@ -468,9 +533,11 @@ char* yep_serialize_json_pretty_ex(const yeptris_document* doc, size_t* len, con
468
533
  em.w.sink_aborted = 0;
469
534
  em.w.flushed = 0;
470
535
  memset(&em.canon_names, 0, sizeof(em.canon_names));
471
- if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
536
+ if (em.w.canonical && !yep_nametab_init(&em.canon_names, emit_sys(doc))) {
472
537
  return NULL;
473
538
  }
539
+ /* raw malloc ON PURPOSE (#904 item 3): the dry-wet pair's exact-
540
+ * sized output is RETURNED — the host's free() owns it */
474
541
  size_t need = yep_emit_run(&em, 1);
475
542
  char* out = malloc(need + 1);
476
543
  if (out == NULL) {
@@ -532,6 +599,8 @@ YEPTRIS_API size_t yeptris_serialize_stream(YeptrisDocument handle,
532
599
  em.w.json_pretty = 0;
533
600
  em.w.pretty_depth = 0;
534
601
  em.w.best_width = opts_width(opts);
602
+ em.w.indent = opts_indent(opts);
603
+ em.w.block_fold = opts_block_fold(opts);
535
604
  em.w.col = 0;
536
605
  em.w.sv_input = handle ? ((const yeptris_document*)handle)->dom->input_base : NULL;
537
606
  em.w.sv_arena = handle ? ((const yeptris_document*)handle)->dom->str : NULL;
@@ -539,11 +608,14 @@ YEPTRIS_API size_t yeptris_serialize_stream(YeptrisDocument handle,
539
608
  em.w.sink_ctx = ctx;
540
609
  em.w.watermark = YEP_EMIT_WATERMARK;
541
610
  memset(&em.canon_names, 0, sizeof(em.canon_names));
542
- if (em.w.canonical && !yep_nametab_init(&em.canon_names, yep_system_allocator())) {
611
+ if (em.w.canonical && !yep_nametab_init(&em.canon_names, emit_sys(em.doc))) {
543
612
  return 0;
544
613
  }
545
- /* one scratch window; the writer flushes it when it fills */
546
- char* window = malloc(YEP_EMIT_WATERMARK * 2);
614
+ /* one scratch window; the writer flushes it when it fills.
615
+ * Document allocator (#904 item 3): emitter-internal scratch —
616
+ * flushed out through the sink, never returned — so the
617
+ * fail-injection harness reaches it. */
618
+ char* window = yep_alloc(emit_sys(em.doc), YEP_EMIT_WATERMARK * 2);
547
619
  if (window == NULL) {
548
620
  if (em.canon_names.sys != NULL) {
549
621
  yep_nametab_free(&em.canon_names);
@@ -564,7 +636,7 @@ YEPTRIS_API size_t yeptris_serialize_stream(YeptrisDocument handle,
564
636
  /* total already counted by the flush hooks */
565
637
  }
566
638
  }
567
- free(window);
639
+ yep_free(emit_sys(em.doc), window);
568
640
  if (em.canon_names.sys != NULL) {
569
641
  yep_nametab_free(&em.canon_names);
570
642
  }