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.
- checksums.yaml +4 -4
- data/ext/yeptris_native/version.h +2 -2
- data/lib/yeptris/3.4/native.so +0 -0
- data/lib/yeptris/psych/visitors.rb +123 -20
- data/lib/yeptris/psych.rb +91 -15
- data/lib/yeptris/yaml.rb +92 -3
- data/lib/yeptris.rb +1 -1
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/CMakeLists.txt +5 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +2 -1
- data/vendor/libyeptris/src/include/yeptris/events.h +7 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +3 -1
- data/vendor/libyeptris/src/include/yeptris/validate.h +157 -0
- data/vendor/libyeptris/src/include/yeptris.h +1 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +56 -20
- data/vendor/libyeptris/src/yeptris/dom/dom.h +5 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +97 -7
- data/vendor/libyeptris/src/yeptris/events/pull.c +25 -5
- data/vendor/libyeptris/src/yeptris/events/push.c +23 -1
- data/vendor/libyeptris/src/yeptris/events/recorder.c +33 -6
- data/vendor/libyeptris/src/yeptris/memory/arena.c +9 -1
- data/vendor/libyeptris/src/yeptris/memory/pool.c +5 -1
- data/vendor/libyeptris/src/yeptris/parse/engine.c +59 -0
- data/vendor/libyeptris/src/yeptris/parse.c +22 -8
- data/vendor/libyeptris/src/yeptris/resolve/json12.c +103 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +9 -0
- data/vendor/libyeptris/src/yeptris/validate/internal.h +102 -0
- data/vendor/libyeptris/src/yeptris/validate/jsonschema.c +1022 -0
- data/vendor/libyeptris/src/yeptris/validate/regexp.c +972 -0
- data/vendor/libyeptris/src/yeptris/validate/validate.c +939 -0
- metadata +7 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23d3c8dc0b4600de5a60826f71cf3ffb2d7517c8a6e0c8f588aee724320782e3
|
|
4
|
+
data.tar.gz: '067915418bf97cccf16cc015e4b78959d45270ff97c8d0372b988b9b3bab1b7c'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47511ed558cbf416de324e79679163e1dabcaecdbe009317c240015c6d063ddb3d212b215af60f8181d0e08c1d863f94ff4b5531362edc95c07f80bb1059f7d0
|
|
7
|
+
data.tar.gz: afc2c53b583f6637902bdeb8e8d506309be3beb412af4d7f664a462332360ec50cb9340bea3909601776ab72a5b6e8aeebfd1ffe1bb22568cc13ccb145e0be96
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
#define YEPTRIS_VERSION_MAJOR 0
|
|
13
13
|
#define YEPTRIS_VERSION_MINOR 6
|
|
14
|
-
#define YEPTRIS_VERSION_PATCH
|
|
15
|
-
#define YEPTRIS_VERSION_STRING "0.6.
|
|
14
|
+
#define YEPTRIS_VERSION_PATCH 58
|
|
15
|
+
#define YEPTRIS_VERSION_STRING "0.6.58"
|
|
16
16
|
|
|
17
17
|
#ifdef __cplusplus
|
|
18
18
|
extern "C" {
|
data/lib/yeptris/3.4/native.so
CHANGED
|
Binary file
|
|
@@ -437,6 +437,10 @@ module Yeptris
|
|
|
437
437
|
when /\A!ruby\/object(?::(.+))?\z/
|
|
438
438
|
klass = resolve_class(Regexp.last_match(1).to_s)
|
|
439
439
|
revive_object(klass, node)
|
|
440
|
+
when /\A!ruby\/hash:(.+)\z/
|
|
441
|
+
revive_hash_class(resolve_class(Regexp.last_match(1)), node)
|
|
442
|
+
when /\A!ruby\/exception(?::(.*))?\z/
|
|
443
|
+
revive_exception(resolve_class(Regexp.last_match(1).to_s), node)
|
|
440
444
|
else
|
|
441
445
|
# Psych.load_tags first (the class registry, #95 bug 4);
|
|
442
446
|
# anything else stays the plain mapping
|
|
@@ -452,9 +456,13 @@ module Yeptris
|
|
|
452
456
|
# key's SHAPE decides (an explicit !!str '<<' is a literal key,
|
|
453
457
|
# not a merge), the VALUE's node kind picks the arm, and every
|
|
454
458
|
# merge is TypeError-guarded (a bad element keeps the whole
|
|
455
|
-
# '<<' pair literal — merges are all-or-nothing).
|
|
456
|
-
|
|
457
|
-
|
|
459
|
+
# '<<' pair literal — merges are all-or-nothing). The anchor
|
|
460
|
+
# registrant is the receiver by default; the object revivals
|
|
461
|
+
# pass the revived OBJ (psych's revive(): the object itself is
|
|
462
|
+
# registered before the children walk, so an alias inside an
|
|
463
|
+
# ivar pointing back at the object resolves to it).
|
|
464
|
+
def hash_into(h, node, anchor: nil)
|
|
465
|
+
anchors[node.anchor] = (anchor || h) if node.anchor
|
|
458
466
|
node.children.each_slice(2) do |k, v|
|
|
459
467
|
key = visit(k)
|
|
460
468
|
val = visit(v)
|
|
@@ -502,29 +510,124 @@ module Yeptris
|
|
|
502
510
|
end
|
|
503
511
|
|
|
504
512
|
def revive_object(klass, node)
|
|
505
|
-
|
|
506
|
-
#
|
|
507
|
-
#
|
|
508
|
-
|
|
513
|
+
obj = klass ? klass.allocate : ::Object.allocate
|
|
514
|
+
# psych's revive(): the object registers BEFORE the children
|
|
515
|
+
# walk — an alias inside the state pointing back at the
|
|
516
|
+
# object resolves to it (identity through ivars)
|
|
517
|
+
anchors[node.anchor] = obj if node.anchor
|
|
509
518
|
|
|
510
|
-
|
|
519
|
+
if klass
|
|
520
|
+
# The yeptris encoder's format (visit_encode_with): the
|
|
521
|
+
# Encodable protocol rides the __init__ marker, so the
|
|
522
|
+
# state passes back through init_with(coder) without
|
|
523
|
+
# library-side ivar reflection. The format decides on the
|
|
524
|
+
# RAW key before any value is visited (the old walk's
|
|
525
|
+
# shape; sibling values stay untouched when it fires).
|
|
526
|
+
init = nil
|
|
527
|
+
node.children.each_slice(2) do |k, v|
|
|
528
|
+
init = v if k.to_ruby.to_s == "__init__"
|
|
529
|
+
end
|
|
530
|
+
if init
|
|
531
|
+
unless klass <= ::Yeptris::Psych::Encodable
|
|
532
|
+
raise ::Yeptris::DumpError,
|
|
533
|
+
"#{klass} is not Yeptris::Psych::Encodable: implement init_with(coder)"
|
|
534
|
+
end
|
|
511
535
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
536
|
+
coder = ::Yeptris::Psych::CoderShim.new
|
|
537
|
+
if init.is_a?(::Yeptris::Psych::Nodes::Mapping)
|
|
538
|
+
init.children.each_slice(2) do |ck, cv|
|
|
539
|
+
coder[ck.to_ruby.to_s] = visit(cv)
|
|
540
|
+
end
|
|
541
|
+
end
|
|
542
|
+
obj.init_with(coder)
|
|
543
|
+
return obj
|
|
544
|
+
end
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
# stdlib psych's format (visit_Object + dump_ivars): the
|
|
548
|
+
# mapping's own top-level pairs ARE the object state —
|
|
549
|
+
# revives through init_with when the class defines it, ivar
|
|
550
|
+
# assignment otherwise. THE AUDIT FIX: the __init__-only
|
|
551
|
+
# walk silently dropped the ivars of every stdlib
|
|
552
|
+
# Psych.dump-produced document.
|
|
553
|
+
init_with_state(obj, hash_into({}, node, anchor: obj), node)
|
|
554
|
+
obj
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
# !ruby/hash:K (stdlib visit_Hash of a Hash subclass): the
|
|
558
|
+
# SUBCLASS allocates and the mapping's own pairs fill it
|
|
559
|
+
# (merge keys included, hash_into semantics). A name that
|
|
560
|
+
# resolves to a non-Hash raises stdlib resolve_subclass's
|
|
561
|
+
# ArgumentError; an unresolvable name stays a plain Hash (the
|
|
562
|
+
# resolve_class-returns-nil convention this binding already
|
|
563
|
+
# applies to !ruby/object and !ruby/struct — safe_load raises
|
|
564
|
+
# DisallowedClass for it first).
|
|
565
|
+
def revive_hash_class(klass, node)
|
|
566
|
+
if klass
|
|
567
|
+
unless klass <= ::Hash
|
|
568
|
+
raise ::ArgumentError, "Invalid tag: expected a subclass of Hash, got #{klass}"
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
h = klass.allocate
|
|
572
|
+
else
|
|
573
|
+
h = {}
|
|
574
|
+
end
|
|
575
|
+
anchors[node.anchor] = h if node.anchor
|
|
576
|
+
hash_into(h, node)
|
|
577
|
+
h
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
# !ruby/exception[:K] (stdlib visit_Exception + build_exception):
|
|
581
|
+
# the message rides the exception's own construction surface
|
|
582
|
+
# (Class#exception — psych's C build_exception writes the
|
|
583
|
+
# engine-internal mesg slot on an allocated instance, which
|
|
584
|
+
# Ruby-level ivar assignment cannot reach: message would stay
|
|
585
|
+
# the class name), backtrace is consumed if present, and every
|
|
586
|
+
# other pair lands as ivars (message/backtrace excepted — they
|
|
587
|
+
# name the exception's own surface, not object state). Bare
|
|
588
|
+
# !ruby/exception rides ::Exception (psych's class_loader
|
|
589
|
+
# exception fallback). A subclass whose initialize refuses a
|
|
590
|
+
# message argument constructs bare — same fallback psych's
|
|
591
|
+
# Ruby-side build_exception carried before the C move.
|
|
592
|
+
def revive_exception(klass, node)
|
|
593
|
+
h = {}
|
|
517
594
|
node.children.each_slice(2) do |k, v|
|
|
518
|
-
|
|
519
|
-
|
|
595
|
+
h[visit(k)] = visit(v)
|
|
596
|
+
end
|
|
597
|
+
mesg = h.delete("message")
|
|
598
|
+
e = build_exception(klass || ::Exception, mesg)
|
|
599
|
+
anchors[node.anchor] = e if node.anchor
|
|
600
|
+
e.set_backtrace(h.delete("backtrace")) if h.key?("backtrace")
|
|
601
|
+
init_with_state(e, h, node)
|
|
602
|
+
e
|
|
603
|
+
end
|
|
520
604
|
|
|
605
|
+
def build_exception(klass, mesg)
|
|
606
|
+
return klass.exception if mesg.nil?
|
|
607
|
+
|
|
608
|
+
begin
|
|
609
|
+
klass.exception(mesg)
|
|
610
|
+
rescue ::ArgumentError, ::TypeError
|
|
611
|
+
klass.exception
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
# psych's init_with: a class defining init_with takes the coder
|
|
616
|
+
# (the raw pair map, coder.tag = the mapping's tag); everything
|
|
617
|
+
# else — bare Object included — takes the pairs as ivars. Keys
|
|
618
|
+
# are @-normalized both ways: stdlib DUMPS the ivars @-stripped
|
|
619
|
+
# (yaml_tree's dump_ivars), older psych and hand-written docs
|
|
620
|
+
# spell them WITH the @ — both map to the same ivar.
|
|
621
|
+
def init_with_state(obj, h, node)
|
|
622
|
+
if obj.respond_to?(:init_with)
|
|
521
623
|
coder = ::Yeptris::Psych::CoderShim.new
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
coder[ck.to_ruby.to_s] = visit(cv)
|
|
525
|
-
end
|
|
526
|
-
end
|
|
624
|
+
coder.tag = node.tag
|
|
625
|
+
h.each { |k, v| coder[k] = v }
|
|
527
626
|
obj.init_with(coder)
|
|
627
|
+
else
|
|
628
|
+
h.each do |k, v|
|
|
629
|
+
obj.instance_variable_set(:"@#{k.to_s.sub(/\A@/, "")}", v)
|
|
630
|
+
end
|
|
528
631
|
end
|
|
529
632
|
obj
|
|
530
633
|
end
|
data/lib/yeptris/psych.rb
CHANGED
|
@@ -208,11 +208,14 @@ module Yeptris
|
|
|
208
208
|
|
|
209
209
|
def safe_load(yaml, permitted_classes: [::Date, ::Time], aliases: false,
|
|
210
210
|
symbolize_names: false, **)
|
|
211
|
+
# ONE read at the boundary (read_input): IO-like input must be
|
|
212
|
+
# consumed once — the string rides parse AND the slice below
|
|
213
|
+
source = ::Yeptris.read_input(yaml)
|
|
211
214
|
begin
|
|
212
|
-
doc = Yeptris::Document.parse(
|
|
215
|
+
doc = Yeptris::Document.parse(source, schema: :compat_11)
|
|
213
216
|
return nil if doc.nil? # the legal empty stream
|
|
214
217
|
|
|
215
|
-
res = force_utf8_scalars(walk_safe(doc.root(0), permitted_classes, aliases))
|
|
218
|
+
res = force_utf8_scalars(walk_safe(doc.root(0), permitted_classes, aliases, source))
|
|
216
219
|
res = deep_symbolize_keys(res) if symbolize_names
|
|
217
220
|
res
|
|
218
221
|
rescue ::Yeptris::ParseError => e
|
|
@@ -290,23 +293,78 @@ module Yeptris
|
|
|
290
293
|
::Yeptris::Psych.dump(obj, io, options)
|
|
291
294
|
end
|
|
292
295
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
# stdlib's load_stream (yeptris#881): every document of the
|
|
297
|
+
# stream, in order — the block form yields each loaded document.
|
|
298
|
+
# The engine's stream parse drives the boundaries (--- / ... /
|
|
299
|
+
# implicit documents after a ...); empty documents are nil
|
|
300
|
+
# elements, exactly what stdlib yields.
|
|
301
|
+
#
|
|
302
|
+
# errors: :raise (default) re-raises a bad document as stdlib's
|
|
303
|
+
# family — Psych::SyntaxError (parse() translates the same way).
|
|
304
|
+
# errors: :collect never raises for a bad document: the stream
|
|
305
|
+
# re-walks at marker boundaries (Yeptris::YAML._stream_slices)
|
|
306
|
+
# through this face's own DOM materialization, and the bad
|
|
307
|
+
# document's position carries the SyntaxError marker.
|
|
308
|
+
def load_stream(yaml, errors: :raise, **kwargs, &block)
|
|
309
|
+
unless %i[raise collect].include?(errors)
|
|
310
|
+
raise ArgumentError, "errors: must be :raise or :collect (got #{errors.inspect})"
|
|
305
311
|
end
|
|
312
|
+
|
|
313
|
+
# once, up front: the collect fallback re-parses this text and
|
|
314
|
+
# an IO input would already be at EOF by then
|
|
315
|
+
yaml = ::Yeptris.read_input(yaml).to_s
|
|
316
|
+
docs =
|
|
317
|
+
begin
|
|
318
|
+
# materialize each document's root directly — the stream
|
|
319
|
+
# children share one C document, so their handles would all
|
|
320
|
+
# resolve to the first document's tree. stdlib's block form
|
|
321
|
+
# yields each loaded document's object (#179 round 4).
|
|
322
|
+
doc = ::Yeptris::Document.parse(yaml, schema: :compat_11)
|
|
323
|
+
if doc.nil?
|
|
324
|
+
# the legal empty stream: stdlib answers a stream object
|
|
325
|
+
# with no children; the array face answers []
|
|
326
|
+
[]
|
|
327
|
+
else
|
|
328
|
+
begin
|
|
329
|
+
(0...doc.document_count).map { |i| doc.root(i).to_ruby }
|
|
330
|
+
ensure
|
|
331
|
+
doc.free
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
rescue ::Yeptris::ParseError => e
|
|
335
|
+
# stdlib's family for a bad document (parse() translates
|
|
336
|
+
# the same way); in collect mode the bad document's
|
|
337
|
+
# position carries the SyntaxError marker instead
|
|
338
|
+
raise SyntaxError.from_parse_error(e) if errors != :collect
|
|
339
|
+
|
|
340
|
+
_collect_stream(yaml)
|
|
341
|
+
end
|
|
306
342
|
docs.each { |d| block.call(d) } if block
|
|
307
343
|
docs
|
|
308
344
|
end
|
|
309
345
|
|
|
346
|
+
# The errors: :collect fallback: parse the marker-boundary
|
|
347
|
+
# slices through this face's own DOM materialization; a failed
|
|
348
|
+
# slice's position carries the SyntaxError marker.
|
|
349
|
+
def _collect_stream(yaml)
|
|
350
|
+
results = []
|
|
351
|
+
::Yeptris::YAML._stream_slices(yaml).each do |slice|
|
|
352
|
+
begin
|
|
353
|
+
doc = ::Yeptris::Document.parse(slice, schema: :compat_11)
|
|
354
|
+
next if doc.nil?
|
|
355
|
+
|
|
356
|
+
begin
|
|
357
|
+
(0...doc.document_count).each { |i| results << doc.root(i).to_ruby }
|
|
358
|
+
ensure
|
|
359
|
+
doc.free
|
|
360
|
+
end
|
|
361
|
+
rescue ::Yeptris::ParseError => e
|
|
362
|
+
results << SyntaxError.from_parse_error(e)
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
results
|
|
366
|
+
end
|
|
367
|
+
|
|
310
368
|
# safe_load_stream: stdlib's surface — the stream form of
|
|
311
369
|
# safe_load. Our load_stream is already safe-by-default
|
|
312
370
|
# (Psych 5 semantics), so this is the yielding wrapper.
|
|
@@ -406,7 +464,25 @@ module Yeptris
|
|
|
406
464
|
# class outside the permitted set raises too (issue #69: a
|
|
407
465
|
# compat_11 date must not become a Date unless Date is
|
|
408
466
|
# permitted — Psych::DisallowedClass semantics).
|
|
409
|
-
|
|
467
|
+
#
|
|
468
|
+
# The single-pass slice (#862): the gate walk IS the cost —
|
|
469
|
+
# per-node FFI reads. Three provable facts retire it for clean
|
|
470
|
+
# documents: the parser cannot build an alias without a `*`
|
|
471
|
+
# byte in the source, cannot build an explicit tag without a
|
|
472
|
+
# `!` byte, and the marshal builder REFUSES timestamps and
|
|
473
|
+
# merge keys (its success proves none exist — every
|
|
474
|
+
# timestamp-typed shape is refused, verified per shape). So
|
|
475
|
+
# `marshal_fast` doubles as the probe AND the build in one C
|
|
476
|
+
# call: on a gate-free source its success proves check() could
|
|
477
|
+
# not have raised, and the walk disappears; a refusal or a gate
|
|
478
|
+
# byte falls back to the checked walk, which is byte-for-byte
|
|
479
|
+
# the old path.
|
|
480
|
+
def walk_safe(root, permitted, aliases_enabled, source = nil)
|
|
481
|
+
if root && !source.nil? &&
|
|
482
|
+
!source.include?("*") && !source.include?("!")
|
|
483
|
+
fast = root.marshal_fast
|
|
484
|
+
return fast unless fast.nil?
|
|
485
|
+
end
|
|
410
486
|
check(root, permitted, aliases_enabled) if root
|
|
411
487
|
root.to_ruby
|
|
412
488
|
end
|
data/lib/yeptris/yaml.rb
CHANGED
|
@@ -44,11 +44,100 @@ module Yeptris
|
|
|
44
44
|
Psych.safe_load(yaml.to_s, permitted_classes: permitted_classes, aliases: aliases)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
# Every document in the stream, in order
|
|
48
|
-
|
|
47
|
+
# Every document in the stream, in order (the multi-document stream
|
|
48
|
+
# API, yeptris#881 — Psych's load_stream parity). Document boundary
|
|
49
|
+
# detection follows the engine's stream parse: explicit --- / ...
|
|
50
|
+
# markers, implicit documents after a ... terminator, and empty
|
|
51
|
+
# documents — nil elements, exactly what Psych yields for them.
|
|
52
|
+
#
|
|
53
|
+
# errors: :raise (default) raises Yeptris::ParseError on the first
|
|
54
|
+
# bad document — psych's behavior (a stream parse cannot resume
|
|
55
|
+
# past it). errors: :collect never raises for a bad document: the
|
|
56
|
+
# text re-walks at marker boundaries (see _stream_slices) and the
|
|
57
|
+
# bad document's position carries a Yeptris::ParseError marker
|
|
58
|
+
# (skip with results.grep(Yeptris::ParseError)). A stream that
|
|
59
|
+
# parses whole collects to the same plain document array as :raise.
|
|
60
|
+
#
|
|
61
|
+
# With a block, every element — documents and, under :collect,
|
|
62
|
+
# error markers — is yielded in order; the array is returned.
|
|
63
|
+
def load_stream(yaml, schema: :compat_11, errors: :raise, &block)
|
|
64
|
+
unless %i[raise collect].include?(errors)
|
|
65
|
+
raise ArgumentError, "errors: must be :raise or :collect (got #{errors.inspect})"
|
|
66
|
+
end
|
|
67
|
+
|
|
49
68
|
yaml = Yeptris.read_input(yaml)
|
|
50
69
|
yaml = yaml.to_s
|
|
51
|
-
|
|
70
|
+
docs =
|
|
71
|
+
begin
|
|
72
|
+
docs = _drain_all(yaml, schema)
|
|
73
|
+
# The value drain emits a nil record even for a stream with
|
|
74
|
+
# ZERO documents ("", a blank line, a comment) — stdlib's
|
|
75
|
+
# load_stream answers zero documents there, and the corner
|
|
76
|
+
# must not mask a real empty document ("---\n" IS [nil]).
|
|
77
|
+
# Only the [nil] shape needs the discriminating DOM count,
|
|
78
|
+
# so the good path pays nothing.
|
|
79
|
+
if docs == [nil]
|
|
80
|
+
doc = Document.parse(yaml, schema: schema)
|
|
81
|
+
docs = [] if doc.nil? || doc.document_count.zero?
|
|
82
|
+
doc&.free
|
|
83
|
+
end
|
|
84
|
+
docs
|
|
85
|
+
rescue ParseError
|
|
86
|
+
raise if errors != :collect
|
|
87
|
+
|
|
88
|
+
_collect_stream(yaml, schema)
|
|
89
|
+
end
|
|
90
|
+
docs.each { |d| block.call(d) } if block
|
|
91
|
+
docs
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# A column-0 --- / ... marker line. A real document boundary in
|
|
95
|
+
# every valid YAML stream (block/scalar content can never carry one
|
|
96
|
+
# unindented), so the scan is exact — it never splits inside a
|
|
97
|
+
# document. Marker-less boundaries (implicit documents after a
|
|
98
|
+
# ...) stay INSIDE their slice, and each slice parses through the
|
|
99
|
+
# full stream face, so nothing is lost there either. Slices keep
|
|
100
|
+
# their marker lines so every slice parses standalone. Used only by
|
|
101
|
+
# the errors: :collect fallback — a stream that parses whole never
|
|
102
|
+
# splits (the fallback's lossy cases are the whole reason #881
|
|
103
|
+
# exists; the good path must stay exact).
|
|
104
|
+
STREAM_MARKER = /\A(?:---|\.\.\.)(?:[ \t]|\r?\n|\z)/
|
|
105
|
+
|
|
106
|
+
# The marker-delimited slices of a stream. A slice that began at a
|
|
107
|
+
# marker line always survives (a trailing bare `---` is an empty
|
|
108
|
+
# document — nil, like psych yields); only a comments/blank-only
|
|
109
|
+
# leading prefix (no document) drops.
|
|
110
|
+
def _stream_slices(yaml)
|
|
111
|
+
slices = []
|
|
112
|
+
current = +""
|
|
113
|
+
markered = false
|
|
114
|
+
yaml.each_line do |line|
|
|
115
|
+
if line.match?(STREAM_MARKER)
|
|
116
|
+
slices << current if markered || !current.strip.empty?
|
|
117
|
+
current = line.dup
|
|
118
|
+
markered = true
|
|
119
|
+
else
|
|
120
|
+
current << line
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
slices << current if markered || !current.strip.empty?
|
|
124
|
+
slices
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# The errors: :collect fallback: parse marker-boundary slices
|
|
128
|
+
# through the full stream face; a failed slice's position carries
|
|
129
|
+
# the ParseError. Documents before the bad one still load — the
|
|
130
|
+
# per-document rescue-and-skip contract, centralized.
|
|
131
|
+
def _collect_stream(yaml, schema)
|
|
132
|
+
results = []
|
|
133
|
+
_stream_slices(yaml).each do |slice|
|
|
134
|
+
begin
|
|
135
|
+
results.concat(_drain_all(slice, schema))
|
|
136
|
+
rescue ParseError => e
|
|
137
|
+
results << e
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
results
|
|
52
141
|
end
|
|
53
142
|
|
|
54
143
|
# The Marshal fast path when the loaded libyeptris has it (>= 0.1.11
|
data/lib/yeptris.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Yeptris
|
|
4
4
|
# The gem's version lives in the parent namespace's file — the last
|
|
5
5
|
# internal require (yeptris/version) retired with it.
|
|
6
|
-
VERSION = "0.6.
|
|
6
|
+
VERSION = "0.6.58.1".freeze
|
|
7
7
|
|
|
8
8
|
# Informational notices are OPT-IN (yeptris-ruby#217): consumers
|
|
9
9
|
# embed yeptris inside CLIs that assert clean stderr, and a
|
data/libyeptris.so
CHANGED
|
Binary file
|
|
@@ -39,9 +39,13 @@ set(YEPTRIS_SOURCES
|
|
|
39
39
|
yeptris/resolve/tags.c
|
|
40
40
|
yeptris/resolve/core12.c
|
|
41
41
|
yeptris/resolve/compat11.c
|
|
42
|
+
yeptris/resolve/json12.c
|
|
42
43
|
yeptris/parse/numbers.c
|
|
43
44
|
yeptris/events/values.c
|
|
44
45
|
yeptris/schema.c
|
|
46
|
+
yeptris/validate/regexp.c
|
|
47
|
+
yeptris/validate/validate.c
|
|
48
|
+
yeptris/validate/jsonschema.c
|
|
45
49
|
yeptris/tape.c
|
|
46
50
|
yeptris/plan.c
|
|
47
51
|
|
|
@@ -95,6 +99,7 @@ set(YEPTRIS_PUBLIC_HEADERS
|
|
|
95
99
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/parse.h
|
|
96
100
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/values.h
|
|
97
101
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/schema.h
|
|
102
|
+
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/validate.h
|
|
98
103
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/tape.h
|
|
99
104
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/plan.h
|
|
100
105
|
${CMAKE_CURRENT_SOURCE_DIR}/include/yeptris/marshal.h
|
|
@@ -25,7 +25,8 @@ typedef enum {
|
|
|
25
25
|
YEPTRIS_ERROR_ARG = 6, /* invalid argument (NULL handle, bad option) */
|
|
26
26
|
YEPTRIS_ERROR_UNSUPPORTED = 7, /* requested feature not built in */
|
|
27
27
|
YEPTRIS_ERROR_INTERNAL = 8, /* invariant violation — a bug, please report */
|
|
28
|
-
YEPTRIS_ERROR_SCHEMA = 9,
|
|
28
|
+
YEPTRIS_ERROR_SCHEMA = 9, /* validation: the report carries diagnostics (#882);
|
|
29
|
+
* descriptor materialization: REQUIRED missing (#238) */
|
|
29
30
|
} YeptrisStatus;
|
|
30
31
|
|
|
31
32
|
/* Message of the most recent failure on the calling thread, with its
|
|
@@ -141,6 +141,13 @@ YEPTRIS_API YeptrisStatus yeptris_recorder_feed(YeptrisRecorder rec, const char*
|
|
|
141
141
|
* the next feed; reset at every feed entry (drain per chunk). */
|
|
142
142
|
YEPTRIS_API const YeptrisEventRecord* yeptris_recorder_records(YeptrisRecorder rec, size_t* count);
|
|
143
143
|
YEPTRIS_API const char* yeptris_recorder_arena(YeptrisRecorder rec, size_t* len);
|
|
144
|
+
|
|
145
|
+
/* Status of the last feed with its 1-based error position (0 = the
|
|
146
|
+
* failure carries no position, e.g. a capture allocation failure).
|
|
147
|
+
* Mirror of yeptris_pull_status / yeptris_iterparse_status. */
|
|
148
|
+
YEPTRIS_API YeptrisStatus yeptris_recorder_status(const YeptrisRecorder rec, uint32_t* line,
|
|
149
|
+
uint32_t* col);
|
|
150
|
+
|
|
144
151
|
YEPTRIS_API void yeptris_recorder_free(YeptrisRecorder rec);
|
|
145
152
|
|
|
146
153
|
/* ---- iterparse -------------------------------------------------------- */
|
|
@@ -40,10 +40,12 @@ typedef enum {
|
|
|
40
40
|
YEPTRIS_TAG_CUSTOM = 11,
|
|
41
41
|
} YeptrisTagId;
|
|
42
42
|
|
|
43
|
-
/* Schemas. */
|
|
43
|
+
/* Schemas. Appending only — bindings hard-code the values (test_abi). */
|
|
44
44
|
typedef enum {
|
|
45
45
|
YEPTRIS_SCHEMA_12_CORE = 0, /* default: the yaml-test-suite target */
|
|
46
46
|
YEPTRIS_SCHEMA_11_COMPAT, /* libyaml/Psych implicit typing */
|
|
47
|
+
YEPTRIS_SCHEMA_12_JSON, /* spec 10.2: JSON productions; plain
|
|
48
|
+
* scalars matching none are errors (#882) */
|
|
47
49
|
} YeptrisSchema;
|
|
48
50
|
|
|
49
51
|
/* Canonical tag URI for a core id ("tag:yaml.org,2002:str"); NULL for
|