yeptris 0.6.7.5 → 0.6.8.2
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/lib/yeptris/cbor.rb +14 -5
- data/lib/yeptris/psych/drop_in.rb +19 -0
- data/lib/yeptris.rb +1 -1
- data/vendor/libyeptris/CMakeLists.txt +1 -1
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +11 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3cd35014222c85dc46a7d9cc3622ae85729d055a218ab89899aaee638d774bb
|
|
4
|
+
data.tar.gz: abab0a3805fad843a6c1ac6e6f09e28e5cd0c3874f6e58e1cc3bf86dbdbaec9b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2af308efb9fc6d825adc204d950ed2c2496fcaad50194015711c6d89dec0c4c32a7630e5644c0edc1df880fa684311d1aa7ddabfb7572e05a9d28d7ae81df1fb
|
|
7
|
+
data.tar.gz: 3ce1d7a886d39e9afafacd94f0869152b0d21cacb548ce49b76b929c7a705163ce8dc996e636a40541d7e334d4a3aa49a0ee3a79488dac55477ebdb570f76303
|
data/lib/yeptris/cbor.rb
CHANGED
|
@@ -41,17 +41,26 @@ module Yeptris
|
|
|
41
41
|
raise Error, "libyeptris has no CBOR support" unless available?
|
|
42
42
|
|
|
43
43
|
items = []
|
|
44
|
+
pending_error = nil
|
|
44
45
|
receiver = ::FFI::Function.new(:int, %i[pointer pointer size_t]) do |_ctx, item, _index|
|
|
45
46
|
# the callback owns the item; materialize then free in place
|
|
46
|
-
# (through the wrapper — the finalizer frees too)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
# (through the wrapper — the finalizer frees too). A raise
|
|
48
|
+
# inside an FFI callback leaves the return value undefined —
|
|
49
|
+
# abort the C iteration cleanly (nonzero) and re-raise after
|
|
50
|
+
begin
|
|
51
|
+
doc = ::Yeptris::Document.new(item)
|
|
52
|
+
items << doc.root&.to_ruby
|
|
53
|
+
doc.free
|
|
54
|
+
0
|
|
55
|
+
rescue ::Exception => e # rubocop:disable Lint/RescueException
|
|
56
|
+
pending_error = e
|
|
57
|
+
1
|
|
58
|
+
end
|
|
51
59
|
end
|
|
52
60
|
st = ::Yeptris::FFI.yeptris_cbor_decode_sequence(
|
|
53
61
|
data, data.bytesize, strict ? STRICT : 0, receiver, nil, nil
|
|
54
62
|
)
|
|
63
|
+
raise pending_error if pending_error
|
|
55
64
|
raise ParseError, ::Yeptris::FFI.last_error_message if st.zero? && !data.empty?
|
|
56
65
|
|
|
57
66
|
items
|
|
@@ -21,3 +21,22 @@ end
|
|
|
21
21
|
# rebind is this file's whole purpose
|
|
22
22
|
Object.class_eval { remove_const(:Psych) } if defined?(::Psych) && !::Psych.equal?(Yeptris::Psych)
|
|
23
23
|
::Psych = Yeptris::Psych
|
|
24
|
+
|
|
25
|
+
# yaml-first boot order: ::YAML still references the ORIGINAL stdlib
|
|
26
|
+
# module object, whose singleton methods route through stdlib's parse
|
|
27
|
+
# stream — the UTF-8 tagging (and every other normalization) never
|
|
28
|
+
# runs (#135's spec/sdo discriminant). Delegate the original's public
|
|
29
|
+
# singleton surface to the Yeptris face so BOTH constants behave
|
|
30
|
+
# identically regardless of which module object a caller holds.
|
|
31
|
+
# ORIGINAL exists only when stdlib psych was already loaded (the
|
|
32
|
+
# drop-in-before-psych order needs no delegation — nothing references
|
|
33
|
+
# the original yet).
|
|
34
|
+
if ::Yeptris::Psych.const_defined?(:ORIGINAL, false)
|
|
35
|
+
::Psych::ORIGINAL.singleton_class.class_eval do
|
|
36
|
+
::Psych::ORIGINAL.singleton_methods(false).each do |m|
|
|
37
|
+
define_method(m) do |*args, **kwargs, &block|
|
|
38
|
+
::Yeptris::Psych.public_send(m, *args, **kwargs, &block)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
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.8.2".freeze
|
|
7
7
|
# The error hierarchy lives in THIS file (the parent namespace's
|
|
8
8
|
# own file): nested constants do not trigger a parent-constant
|
|
9
9
|
# autoload, and the law forbids internal requires — defining the
|
|
@@ -560,17 +560,25 @@ static size_t cbor_size_item(cenc* e, uint32_t id) {
|
|
|
560
560
|
/* mapping */
|
|
561
561
|
uint32_t pairs = n->count / 2;
|
|
562
562
|
sz += cbor_arg_bytes(pairs);
|
|
563
|
-
|
|
563
|
+
/* hold the INDEX, not the pointer: sizing a child recurses into
|
|
564
|
+
* nested maps whose preps REALLOC e->maps (#152 — a held cmap*
|
|
565
|
+
* dangled and the next pair read walked freed memory; n>=11 of
|
|
566
|
+
* the depth-3 users shape crossed the 16->32 growth) */
|
|
567
|
+
size_t canon_mi = 0;
|
|
568
|
+
int canon = 0;
|
|
564
569
|
if (e->canonical) {
|
|
565
570
|
if (!cbor_canon_prepare(e, id, pairs)) {
|
|
566
571
|
return 0;
|
|
567
572
|
}
|
|
568
|
-
|
|
573
|
+
canon_mi = e->nmaps - 1;
|
|
574
|
+
canon = 1;
|
|
569
575
|
}
|
|
570
|
-
if (
|
|
576
|
+
if (canon) {
|
|
571
577
|
for (uint32_t p = 0; p < pairs && !e->failed; p++) {
|
|
578
|
+
const cmap* cm = &e->maps[canon_mi];
|
|
572
579
|
sz += cbor_size_item(e, cm->child[cm->order[p] * 2]);
|
|
573
580
|
if (!e->failed) {
|
|
581
|
+
cm = &e->maps[canon_mi];
|
|
574
582
|
sz += cbor_size_item(e, cm->child[cm->order[p] * 2 + 1]);
|
|
575
583
|
}
|
|
576
584
|
}
|