psych 3.3.0 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +9 -2
- data/ext/psych/yaml/loader.c +1 -1
- data/ext/psych/yaml/scanner.c +2 -2
- data/ext/psych/yaml/yaml.h +4 -4
- data/ext/psych/yaml/yaml_private.h +1 -1
- data/lib/psych/handler.rb +1 -1
- data/lib/psych/nodes/scalar.rb +1 -1
- data/lib/psych/scalar_scanner.rb +2 -2
- data/lib/psych/versions.rb +3 -3
- data/lib/psych/visitors/to_ruby.rb +12 -8
- data/lib/psych/visitors/visitor.rb +1 -1
- data/lib/psych/visitors/yaml_tree.rb +10 -10
- data/lib/psych.rb +5 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab33b3e081eddfe97a36c85999f28382fd20b2dbcd8aac941f90751c69f733ba
|
4
|
+
data.tar.gz: b122c4ebf121f09e037e2e413b8ba1f175ab7accaa82fbba2d185a19a523ddf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f36f66a35ad33a9bcae5da4f409759caa34194c4dbcaf15db1bb4ad85adfaa7770c36bbd2033a01b7ae7e5795728236fcae9f89b19ce82b44efc31a19d308199
|
7
|
+
data.tar.gz: 65dc5949be1c0e2e3cd4d25db9b8deefda352723ed0a2711a57727fe2ecf3da24a8b824b41b6bcf016bf8a2049085ffbb4b94e57aeccc4e2b79bde9cb6ffa097
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -3,8 +3,8 @@ Bundler::GemHelper.install_tasks
|
|
3
3
|
|
4
4
|
require "rake/testtask"
|
5
5
|
Rake::TestTask.new(:test) do |t|
|
6
|
-
t.libs << "test"
|
7
|
-
t.
|
6
|
+
t.libs << "test/lib" << "test"
|
7
|
+
t.ruby_opts << "-rhelper"
|
8
8
|
t.test_files = FileList['test/**/test_*.rb']
|
9
9
|
t.verbose = true
|
10
10
|
t.warning = true
|
@@ -31,4 +31,11 @@ else
|
|
31
31
|
Rake::ExtensionTask.new("psych")
|
32
32
|
end
|
33
33
|
|
34
|
+
task :sync_tool do
|
35
|
+
require 'fileutils'
|
36
|
+
FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
|
37
|
+
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
38
|
+
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
39
|
+
end
|
40
|
+
|
34
41
|
task :default => [:compile, :test]
|
data/ext/psych/yaml/loader.c
CHANGED
data/ext/psych/yaml/scanner.c
CHANGED
@@ -273,7 +273,7 @@
|
|
273
273
|
* The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
|
274
274
|
* increase that precedes a block collection (cf. the INDENT token in Python).
|
275
275
|
* The token BLOCK-END denote indentation decrease that ends a block collection
|
276
|
-
* (cf. the DEDENT token in Python). However YAML has some syntax
|
276
|
+
* (cf. the DEDENT token in Python). However YAML has some syntax peculiarities
|
277
277
|
* that makes detections of these tokens more complex.
|
278
278
|
*
|
279
279
|
* The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
|
@@ -3287,7 +3287,7 @@ yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
|
|
3287
3287
|
|
3288
3288
|
/* Check if we are at the end of the scalar. */
|
3289
3289
|
|
3290
|
-
/* Fix for crash
|
3290
|
+
/* Fix for crash uninitialized value crash
|
3291
3291
|
* Credit for the bug and input is to OSS Fuzz
|
3292
3292
|
* Credit for the fix to Alex Gaynor
|
3293
3293
|
*/
|
data/ext/psych/yaml/yaml.h
CHANGED
@@ -1095,7 +1095,7 @@ typedef struct yaml_parser_s {
|
|
1095
1095
|
yaml_error_type_t error;
|
1096
1096
|
/** Error description. */
|
1097
1097
|
const char *problem;
|
1098
|
-
/** The byte about which the problem
|
1098
|
+
/** The byte about which the problem occurred. */
|
1099
1099
|
size_t problem_offset;
|
1100
1100
|
/** The problematic value (@c -1 is none). */
|
1101
1101
|
int problem_value;
|
@@ -1335,7 +1335,7 @@ yaml_parser_delete(yaml_parser_t *parser);
|
|
1335
1335
|
* Set a string input.
|
1336
1336
|
*
|
1337
1337
|
* Note that the @a input pointer must be valid while the @a parser object
|
1338
|
-
* exists. The application is responsible for
|
1338
|
+
* exists. The application is responsible for destroying @a input after
|
1339
1339
|
* destroying the @a parser.
|
1340
1340
|
*
|
1341
1341
|
* @param[in,out] parser A parser object.
|
@@ -1734,7 +1734,7 @@ typedef struct yaml_emitter_s {
|
|
1734
1734
|
size_t length;
|
1735
1735
|
/** Does the scalar contain line breaks? */
|
1736
1736
|
int multiline;
|
1737
|
-
/** Can the scalar be
|
1737
|
+
/** Can the scalar be expressed in the flow plain style? */
|
1738
1738
|
int flow_plain_allowed;
|
1739
1739
|
/** Can the scalar be expressed in the block plain style? */
|
1740
1740
|
int block_plain_allowed;
|
@@ -1950,7 +1950,7 @@ yaml_emitter_close(yaml_emitter_t *emitter);
|
|
1950
1950
|
/**
|
1951
1951
|
* Emit a YAML document.
|
1952
1952
|
*
|
1953
|
-
* The
|
1953
|
+
* The document object may be generated using the yaml_parser_load() function
|
1954
1954
|
* or the yaml_document_initialize() function. The emitter takes the
|
1955
1955
|
* responsibility for the document object and destroys its content after
|
1956
1956
|
* it is emitted. The document object is destroyed even if the function fails.
|
data/lib/psych/handler.rb
CHANGED
@@ -119,7 +119,7 @@ module Psych
|
|
119
119
|
# +tag+ is an associated tag or nil
|
120
120
|
# +plain+ is a boolean value
|
121
121
|
# +quoted+ is a boolean value
|
122
|
-
# +style+ is an integer
|
122
|
+
# +style+ is an integer indicating the string style
|
123
123
|
#
|
124
124
|
# See the constants in Psych::Nodes::Scalar for the possible values of
|
125
125
|
# +style+
|
data/lib/psych/nodes/scalar.rb
CHANGED
data/lib/psych/scalar_scanner.rb
CHANGED
@@ -34,7 +34,7 @@ module Psych
|
|
34
34
|
|
35
35
|
# Check for a String type, being careful not to get caught by hash keys, hex values, and
|
36
36
|
# special floats (e.g., -.inf).
|
37
|
-
if string.match?(
|
37
|
+
if string.match?(%r{^[^\d.:-]?[[:alpha:]_\s!@#$%\^&*(){}<>|/\\~;=]+}) || string.match?(/\n/)
|
38
38
|
return string if string.length > 5
|
39
39
|
|
40
40
|
if string.match?(/^[^ytonf~]/i)
|
@@ -57,7 +57,7 @@ module Psych
|
|
57
57
|
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
|
58
58
|
require 'date'
|
59
59
|
begin
|
60
|
-
class_loader.date.strptime(string, '%
|
60
|
+
class_loader.date.strptime(string, '%F', Date::GREGORIAN)
|
61
61
|
rescue ArgumentError
|
62
62
|
string
|
63
63
|
end
|
data/lib/psych/versions.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
1
|
# frozen_string_literal: true
|
2
|
+
|
3
3
|
module Psych
|
4
4
|
# The version of Psych you are using
|
5
|
-
VERSION = '3.3.
|
5
|
+
VERSION = '3.3.3'
|
6
6
|
|
7
7
|
if RUBY_ENGINE == 'jruby'
|
8
|
-
DEFAULT_SNAKEYAML_VERSION = '1.
|
8
|
+
DEFAULT_SNAKEYAML_VERSION = '1.31'.freeze
|
9
9
|
end
|
10
10
|
end
|
@@ -24,6 +24,7 @@ module Psych
|
|
24
24
|
super()
|
25
25
|
@st = {}
|
26
26
|
@ss = ss
|
27
|
+
@load_tags = Psych.load_tags
|
27
28
|
@domain_types = Psych.domain_types
|
28
29
|
@class_loader = class_loader
|
29
30
|
@symbolize_names = symbolize_names
|
@@ -48,7 +49,7 @@ module Psych
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def deserialize o
|
51
|
-
if klass = resolve_class(
|
52
|
+
if klass = resolve_class(@load_tags[o.tag])
|
52
53
|
instance = klass.allocate
|
53
54
|
|
54
55
|
if instance.respond_to?(:init_with)
|
@@ -79,7 +80,9 @@ module Psych
|
|
79
80
|
when "!ruby/object:DateTime"
|
80
81
|
class_loader.date_time
|
81
82
|
require 'date' unless defined? DateTime
|
82
|
-
@ss.parse_time(o.value)
|
83
|
+
t = @ss.parse_time(o.value)
|
84
|
+
DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
|
85
|
+
(t.subsec/86400)
|
83
86
|
when '!ruby/encoding'
|
84
87
|
::Encoding.find o.value
|
85
88
|
when "!ruby/object:Complex"
|
@@ -128,7 +131,7 @@ module Psych
|
|
128
131
|
end
|
129
132
|
|
130
133
|
def visit_Psych_Nodes_Sequence o
|
131
|
-
if klass = resolve_class(
|
134
|
+
if klass = resolve_class(@load_tags[o.tag])
|
132
135
|
instance = klass.allocate
|
133
136
|
|
134
137
|
if instance.respond_to?(:init_with)
|
@@ -160,8 +163,8 @@ module Psych
|
|
160
163
|
end
|
161
164
|
|
162
165
|
def visit_Psych_Nodes_Mapping o
|
163
|
-
if
|
164
|
-
return revive(resolve_class(
|
166
|
+
if @load_tags[o.tag]
|
167
|
+
return revive(resolve_class(@load_tags[o.tag]), o)
|
165
168
|
end
|
166
169
|
return revive_hash(register(o, {}), o) unless o.tag
|
167
170
|
|
@@ -326,6 +329,7 @@ module Psych
|
|
326
329
|
end
|
327
330
|
|
328
331
|
private
|
332
|
+
|
329
333
|
def register node, object
|
330
334
|
@st[node.anchor] = object if node.anchor
|
331
335
|
object
|
@@ -337,7 +341,7 @@ module Psych
|
|
337
341
|
list
|
338
342
|
end
|
339
343
|
|
340
|
-
def revive_hash hash, o
|
344
|
+
def revive_hash hash, o, tagged= false
|
341
345
|
o.children.each_slice(2) { |k,v|
|
342
346
|
key = accept(k)
|
343
347
|
val = accept(v)
|
@@ -364,7 +368,7 @@ module Psych
|
|
364
368
|
hash[key] = val
|
365
369
|
end
|
366
370
|
else
|
367
|
-
if @symbolize_names
|
371
|
+
if !tagged && @symbolize_names && key.is_a?(String)
|
368
372
|
key = key.to_sym
|
369
373
|
elsif !@freeze
|
370
374
|
key = deduplicate(key)
|
@@ -402,7 +406,7 @@ module Psych
|
|
402
406
|
|
403
407
|
def revive klass, node
|
404
408
|
s = register(node, klass.allocate)
|
405
|
-
init_with(s, revive_hash({}, node), node)
|
409
|
+
init_with(s, revive_hash({}, node, true), node)
|
406
410
|
end
|
407
411
|
|
408
412
|
def init_with o, h, node
|
@@ -17,7 +17,7 @@ module Psych
|
|
17
17
|
|
18
18
|
if defined?(Ractor)
|
19
19
|
def dispatch
|
20
|
-
Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache
|
20
|
+
@dispatch_cache ||= (Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache)
|
21
21
|
end
|
22
22
|
else
|
23
23
|
DISPATCH = dispatch_cache
|
@@ -192,12 +192,13 @@ module Psych
|
|
192
192
|
register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
|
193
193
|
end
|
194
194
|
|
195
|
+
def visit_Date o
|
196
|
+
register o, visit_Integer(o.gregorian)
|
197
|
+
end
|
198
|
+
|
195
199
|
def visit_DateTime o
|
196
|
-
|
197
|
-
|
198
|
-
else
|
199
|
-
o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
|
200
|
-
end
|
200
|
+
t = o.italy
|
201
|
+
formatted = format_time t, t.offset.zero?
|
201
202
|
tag = '!ruby/object:DateTime'
|
202
203
|
register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
|
203
204
|
end
|
@@ -235,7 +236,6 @@ module Psych
|
|
235
236
|
end
|
236
237
|
alias :visit_TrueClass :visit_Integer
|
237
238
|
alias :visit_FalseClass :visit_Integer
|
238
|
-
alias :visit_Date :visit_Integer
|
239
239
|
|
240
240
|
def visit_Float o
|
241
241
|
if o.nan?
|
@@ -480,8 +480,8 @@ module Psych
|
|
480
480
|
@emitter.end_mapping
|
481
481
|
end
|
482
482
|
|
483
|
-
def format_time time
|
484
|
-
if
|
483
|
+
def format_time time, utc = time.utc?
|
484
|
+
if utc
|
485
485
|
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
|
486
486
|
else
|
487
487
|
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
|
@@ -509,9 +509,9 @@ module Psych
|
|
509
509
|
def emit_coder c, o
|
510
510
|
case c.type
|
511
511
|
when :scalar
|
512
|
-
@emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false,
|
512
|
+
@emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, c.style
|
513
513
|
when :seq
|
514
|
-
@emitter.start_sequence nil, c.tag, c.tag.nil?,
|
514
|
+
@emitter.start_sequence nil, c.tag, c.tag.nil?, c.style
|
515
515
|
c.seq.each do |thing|
|
516
516
|
accept thing
|
517
517
|
end
|
data/lib/psych.rb
CHANGED
@@ -271,7 +271,7 @@ module Psych
|
|
271
271
|
# YAML documents that are supplied via user input. Instead, please use the
|
272
272
|
# safe_load method.
|
273
273
|
#
|
274
|
-
def self.
|
274
|
+
def self.unsafe_load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
|
275
275
|
if legacy_filename != NOT_GIVEN
|
276
276
|
warn_with_uplevel 'Passing filename with the 2nd argument of Psych.load is deprecated. Use keyword argument like Psych.load(yaml, filename: ...) instead.', uplevel: 1 if $VERBOSE
|
277
277
|
filename = legacy_filename
|
@@ -281,6 +281,7 @@ module Psych
|
|
281
281
|
return fallback unless result
|
282
282
|
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
|
283
283
|
end
|
284
|
+
class << self; alias :load :unsafe_load; end
|
284
285
|
|
285
286
|
###
|
286
287
|
# Safely load the yaml string in +yaml+. By default, only the following
|
@@ -577,11 +578,12 @@ module Psych
|
|
577
578
|
# NOTE: This method *should not* be used to parse untrusted documents, such as
|
578
579
|
# YAML documents that are supplied via user input. Instead, please use the
|
579
580
|
# safe_load_file method.
|
580
|
-
def self.
|
581
|
+
def self.unsafe_load_file filename, **kwargs
|
581
582
|
File.open(filename, 'r:bom|utf-8') { |f|
|
582
|
-
self.
|
583
|
+
self.unsafe_load f, filename: filename, **kwargs
|
583
584
|
}
|
584
585
|
end
|
586
|
+
class << self; alias :load_file :unsafe_load_file; end
|
585
587
|
|
586
588
|
###
|
587
589
|
# Safely loads the document contained in +filename+. Returns the yaml contained in
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: psych
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: |
|
16
16
|
Psych is a YAML parser and emitter. Psych leverages libyaml[https://pyyaml.org/wiki/LibYAML]
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.3.7
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Psych is a YAML parser and emitter
|