yeptris 0.6.28.6 → 0.6.29.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89f169b4286f1630dfd386ebdd39c710292231de7dca13d35c5ae11b63eec0bf
4
- data.tar.gz: 209ec594ca38d57ca34155de171688a24bcd28e73226bb5d3e94f68b33773e54
3
+ metadata.gz: 7651542429f94334197d4065c3742763cbd56cf9910e572fd0bc4350a6ee9af8
4
+ data.tar.gz: 51cb4f4e38ad1347f29ab35372c83ef4d132b54556df34e4657ca03874a627b3
5
5
  SHA512:
6
- metadata.gz: 7a317d28c22b3cedc053d29d6c1b03f30c73067d37223cbe2e195a3b7d837fcd33b3a42f14f4e81e313dc3aa422a7c2905d6ace7aac4d4e357a2d6db0c8fb2ed
7
- data.tar.gz: 5c15dae41a30d026feeb121e1734d0e1a40e73432fbdfe7d63b0b46382c1f116dc1767817a0ca2bda6f9fcb533bf04a98a5d3a5aac314660a99bed8fa3cfb40e
6
+ metadata.gz: 9953f85b1cf9f192102ff6ed71c276719c8cdf537c63cbf95e9940c8093c08783e2ec8773aa763f38b5bf2bf71ea5017a252c45b9af726cf6629fb23cd7fa036
7
+ data.tar.gz: 04b77e4bba61b1bf7382a1957c42df0ae129cef5f3f9f16b1b049b6004a1243b2540f88172931ecf835b00ee92eb2b5d462aa235a5109d122dd93a9f9236e2a9
data/lib/yeptris/node.rb CHANGED
@@ -394,6 +394,19 @@ class Yeptris::Node
394
394
  def scalar_to_ruby
395
395
  return symbolize if symbol? && tag_id == :str
396
396
 
397
+ # !ruby/symbol (#258): psych deserializes the scalar to a Symbol
398
+ # (both spellings; safety is walk_safe's permitted_classes gate)
399
+ if tag == "!ruby/symbol" || tag == "tag:ruby.yaml.org,2002:symbol"
400
+ return value.to_s.to_sym
401
+ end
402
+
403
+ # scanner-coercion primitives (psych's ClassLoader-free path)
404
+ case tag
405
+ when "!ruby/string", "tag:ruby.yaml.org,2002:string" then return value.to_s
406
+ when "!ruby/integer", "tag:ruby.yaml.org,2002:integer" then return value.to_i
407
+ when "!ruby/float", "tag:ruby.yaml.org,2002:float" then return value.to_f
408
+ end
409
+
397
410
  # stdlib deserialize's tagged-scalar arms: the class tag carries
398
411
  # DateTime (dumped tagged — a plain timestamp re-loads as Time)
399
412
  if tag == "!ruby/object:DateTime"
data/lib/yeptris/psych.rb CHANGED
@@ -401,6 +401,42 @@ module Yeptris
401
401
  PERMITTED_BY_DEFAULT = [TrueClass, FalseClass, NilClass, Integer, Float,
402
402
  String, Array, Hash].freeze
403
403
 
404
+ CORE_TAGS = %w[str int float bool null timestamp seq map merge value
405
+ binary].freeze
406
+
407
+ # Both tag spellings to the "ruby/…" short form: the engine may
408
+ # hand either the "!ruby/symbol" shorthand or the
409
+ # "tag:ruby.yaml.org,2002:…" URI spelling.
410
+ def ruby_tag_short(tag)
411
+ t = tag.sub(/\A!/, "")
412
+ return t if t.start_with?("ruby/")
413
+ t.sub(/\Atag:ruby\.yaml\.org,2002:/, "ruby/")
414
+ end
415
+
416
+ # psych's scanner coercion path — always allowed, no class
417
+ # loader involved (verified against stdlib: !ruby/string with no
418
+ # permitted_classes loads fine)
419
+ RUBY_TAG_PRIMITIVES = %w[ruby/string ruby/integer ruby/float].freeze
420
+
421
+ # The class a !ruby/… tag names (psych's resolve_class face):
422
+ # "ruby/symbol" → Symbol; "ruby/object:Foo" and the collection
423
+ # forms "ruby/hash:Foo" name Foo. Nil = not a class-shaped ruby
424
+ # tag (or unresolvable) — the caller raises DisallowedClass.
425
+ RUBY_TAG_SINGLETONS = {
426
+ "ruby/symbol" => ::Symbol,
427
+ }.freeze
428
+
429
+ def ruby_tag_class(short)
430
+ return RUBY_TAG_SINGLETONS[short] if RUBY_TAG_SINGLETONS.key?(short)
431
+
432
+ rest = short[/\Aruby\/(?:object|hash|array|struct|exception)(?::(.*))?\z/, 1]
433
+ return nil if rest.nil? || rest.empty?
434
+ rest.split("::").inject(Object) do |mod, part|
435
+ return nil unless mod.const_defined?(part, false)
436
+ mod.const_get(part, false)
437
+ end
438
+ end
439
+
404
440
  def check(node, permitted, aliases_enabled)
405
441
  case node.kind
406
442
  when :alias
@@ -411,9 +447,19 @@ module Yeptris
411
447
  # both tag spellings pass: the URI form's last segment and
412
448
  # the short "!binary" shorthand (#168's cassettes carry it)
413
449
  name = tag.split(":").last.sub(/\A!/, "")
414
- unless %w[str int float bool null timestamp seq map merge value
415
- binary].include?(name)
416
- raise DisallowedClass, name
450
+ unless CORE_TAGS.include?(name)
451
+ # #258: !ruby/… tags follow psych's ClassLoader rules —
452
+ # the scalar primitives (string/integer/float) coerce
453
+ # through the scanner and are allowed as-is; !ruby/symbol
454
+ # passes exactly when Symbol is in permitted_classes;
455
+ # class-bearing forms (ruby/object:K, ruby/hash:K, …)
456
+ # pass when K is in permitted_classes
457
+ short = ruby_tag_short(tag)
458
+ unless RUBY_TAG_PRIMITIVES.include?(short)
459
+ klass = ruby_tag_class(short)
460
+ raise DisallowedClass, name if klass.nil?
461
+ raise DisallowedClass, name unless permitted.include?(klass)
462
+ end
417
463
  end
418
464
  end
419
465
  if node.kind == :scalar && node.tag_id == :timestamp &&
data/lib/yeptris/yaml.rb CHANGED
@@ -269,12 +269,16 @@ module Yeptris
269
269
  return false if "-?:".include?(c) && (s.length == 1 || s[1] =~ /[ \t]/)
270
270
  return false if s.include?(": ") || s.end_with?(":") || s.include?(" #")
271
271
  return false if RESHAPES_SET[s]
272
- # compat's float grammar REQUIRES the dot ("1e3" re-reads as a
273
- # String and may dump plain); ints/sexagesimals still reshape.
274
- # psych's FLOAT has no trailing [.:] group — "1.2.3" is a
275
- # String and dumps plain (pinned by spec/yaml_spec.rb)
276
- return false if s.match?(/\A[-+]?(0|[1-9][0-9_]*)(:[0-5]?[0-9])+\z/)
272
+ # ints/sexagesimals reshape: the compat resolver accepts any
273
+ # digit start (compat11.c), psych's ScalarScanner likewise —
274
+ # "07:00:00" plain re-reads as Integer, so leading-zero hours
275
+ # quote too (psych dumps them quoted)
276
+ return false if s.match?(/\A[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\z/)
277
277
  return false if s.match?(/\A[-+]?(0|[1-9][0-9_]*)\z/)
278
+ # compat's float grammar REQUIRES the dot ("1e3" re-reads as a
279
+ # String and may dump plain); psych's FLOAT has no trailing
280
+ # [.:] group — "1.2.3" is a String and dumps plain (pinned by
281
+ # spec/yaml_spec.rb)
278
282
  return false if s.match?(/\A[-+]?[0-9][0-9_]*\.[0-9_]*([eE][-+]?[0-9]+)?\z/)
279
283
  return false if s.match?(/\A[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]*\z/)
280
284
  return false if s.match?(/\A[-+]?(0x[0-9a-fA-F_]+|0b[01_]+|0o?[0-7_]+)\z/)
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.28.6".freeze
6
+ VERSION = "0.6.29.2".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
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(yeptris
6
- VERSION 0.6.28
6
+ VERSION 0.6.29
7
7
  DESCRIPTION "Ultra-fast YAML 1.2 parser, emitter and streamer in C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -3060,7 +3060,14 @@ static int e_parse_value(yep_engine* e, yep_ctx ctx, uint16_t floor_col) {
3060
3060
  * continue the value even at the parent column ("k:\n!!seq\n[a]"). */
3061
3061
  if (li.indent > floor_col || e->depth == 0 ||
3062
3062
  (ctx == YEP_CTX_AFTER_Q && li.indent == floor_col && li.first != ':') ||
3063
- ((li.first == '[' || li.first == '{') && li.indent == floor_col)) {
3063
+ ((li.first == '[' || li.first == '{') && li.indent == floor_col) ||
3064
+ /* libyaml never validates a block-scalar HEADER's column —
3065
+ * only the content must out-indent the parent (e_block_scalar
3066
+ * enforces that), so "|" / ">" at the key's own column is the
3067
+ * pending value (yeptris-ruby#258: the metanorma collection
3068
+ * fixture shape) */
3069
+ (vctx == YEP_CTX_VALUE_LINE && (li.first == '|' || li.first == '>') &&
3070
+ li.indent == floor_col)) {
3064
3071
  e->pos += li.indent;
3065
3072
  return e_node(e, vctx, floor_col);
3066
3073
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.28.6
4
+ version: 0.6.29.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-04 00:00:00.000000000 Z
11
+ date: 2026-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi