summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-11-11 20:39:22 +0900
committernagachika <nagachika@ruby-lang.org>2021-11-22 10:51:35 +0900
commit5afefe4371b19155fc4d692a5ff2616ad748e9cc (patch)
treec5c8e0394dece73dc33becd094655147e2919dcb /ext
parent5a6f8462dc00ae453268eb7b42b1d395b9f644f8 (diff)
Bump psych version to 3.3.2
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/lib/psych.rb8
-rw-r--r--ext/psych/lib/psych/handler.rb2
-rw-r--r--ext/psych/lib/psych/nodes/scalar.rb2
-rw-r--r--ext/psych/lib/psych/versions.rb6
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb16
-rw-r--r--ext/psych/lib/psych/visitors/visitor.rb2
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb4
-rw-r--r--ext/psych/yaml/loader.c2
-rw-r--r--ext/psych/yaml/scanner.c4
-rw-r--r--ext/psych/yaml/yaml.h8
-rw-r--r--ext/psych/yaml/yaml_private.h2
11 files changed, 30 insertions, 26 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index cedf0a4ad6..34d2218549 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -271,7 +271,7 @@ module Psych
# YAML documents that are supplied via user input. Instead, please use the
# safe_load method.
#
- def self.load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
+ def self.unsafe_load yaml, legacy_filename = NOT_GIVEN, filename: nil, fallback: false, symbolize_names: false, freeze: false
if legacy_filename != NOT_GIVEN
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
filename = legacy_filename
@@ -281,6 +281,7 @@ module Psych
return fallback unless result
result.to_ruby(symbolize_names: symbolize_names, freeze: freeze)
end
+ class << self; alias :load :unsafe_load; end
###
# Safely load the yaml string in +yaml+. By default, only the following
@@ -577,11 +578,12 @@ module Psych
# NOTE: This method *should not* be used to parse untrusted documents, such as
# YAML documents that are supplied via user input. Instead, please use the
# safe_load_file method.
- def self.load_file filename, **kwargs
+ def self.unsafe_load_file filename, **kwargs
File.open(filename, 'r:bom|utf-8') { |f|
- self.load f, filename: filename, **kwargs
+ self.unsafe_load f, filename: filename, **kwargs
}
end
+ class << self; alias :load_file :unsafe_load_file; end
###
# Safely loads the document contained in +filename+. Returns the yaml contained in
diff --git a/ext/psych/lib/psych/handler.rb b/ext/psych/lib/psych/handler.rb
index 8f23e366fa..ad7249ff77 100644
--- a/ext/psych/lib/psych/handler.rb
+++ b/ext/psych/lib/psych/handler.rb
@@ -119,7 +119,7 @@ module Psych
# +tag+ is an associated tag or nil
# +plain+ is a boolean value
# +quoted+ is a boolean value
- # +style+ is an integer idicating the string style
+ # +style+ is an integer indicating the string style
#
# See the constants in Psych::Nodes::Scalar for the possible values of
# +style+
diff --git a/ext/psych/lib/psych/nodes/scalar.rb b/ext/psych/lib/psych/nodes/scalar.rb
index e2616b6a84..5550b616a3 100644
--- a/ext/psych/lib/psych/nodes/scalar.rb
+++ b/ext/psych/lib/psych/nodes/scalar.rb
@@ -50,7 +50,7 @@ module Psych
# +tag+ is an associated tag or nil
# +plain+ is a boolean value
# +quoted+ is a boolean value
- # +style+ is an integer idicating the string style
+ # +style+ is an integer indicating the string style
#
# == See Also
#
diff --git a/ext/psych/lib/psych/versions.rb b/ext/psych/lib/psych/versions.rb
index 488f86e0b4..acb21336c4 100644
--- a/ext/psych/lib/psych/versions.rb
+++ b/ext/psych/lib/psych/versions.rb
@@ -1,10 +1,10 @@
-
# frozen_string_literal: true
+
module Psych
# The version of Psych you are using
- VERSION = '3.3.0'
+ VERSION = '3.3.2'
if RUBY_ENGINE == 'jruby'
- DEFAULT_SNAKEYAML_VERSION = '1.26'.freeze
+ DEFAULT_SNAKEYAML_VERSION = '1.28'.freeze
end
end
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index ec80701917..4de7f80d33 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -24,6 +24,7 @@ module Psych
super()
@st = {}
@ss = ss
+ @load_tags = Psych.load_tags
@domain_types = Psych.domain_types
@class_loader = class_loader
@symbolize_names = symbolize_names
@@ -48,7 +49,7 @@ module Psych
end
def deserialize o
- if klass = resolve_class(Psych.load_tags[o.tag])
+ if klass = resolve_class(@load_tags[o.tag])
instance = klass.allocate
if instance.respond_to?(:init_with)
@@ -128,7 +129,7 @@ module Psych
end
def visit_Psych_Nodes_Sequence o
- if klass = resolve_class(Psych.load_tags[o.tag])
+ if klass = resolve_class(@load_tags[o.tag])
instance = klass.allocate
if instance.respond_to?(:init_with)
@@ -160,8 +161,8 @@ module Psych
end
def visit_Psych_Nodes_Mapping o
- if Psych.load_tags[o.tag]
- return revive(resolve_class(Psych.load_tags[o.tag]), o)
+ if @load_tags[o.tag]
+ return revive(resolve_class(@load_tags[o.tag]), o)
end
return revive_hash(register(o, {}), o) unless o.tag
@@ -326,6 +327,7 @@ module Psych
end
private
+
def register node, object
@st[node.anchor] = object if node.anchor
object
@@ -337,7 +339,7 @@ module Psych
list
end
- def revive_hash hash, o
+ def revive_hash hash, o, tagged= false
o.children.each_slice(2) { |k,v|
key = accept(k)
val = accept(v)
@@ -364,7 +366,7 @@ module Psych
hash[key] = val
end
else
- if @symbolize_names
+ if !tagged && @symbolize_names && key.is_a?(String)
key = key.to_sym
elsif !@freeze
key = deduplicate(key)
@@ -402,7 +404,7 @@ module Psych
def revive klass, node
s = register(node, klass.allocate)
- init_with(s, revive_hash({}, node), node)
+ init_with(s, revive_hash({}, node, true), node)
end
def init_with o, h, node
diff --git a/ext/psych/lib/psych/visitors/visitor.rb b/ext/psych/lib/psych/visitors/visitor.rb
index e2585c0c77..21052aa66f 100644
--- a/ext/psych/lib/psych/visitors/visitor.rb
+++ b/ext/psych/lib/psych/visitors/visitor.rb
@@ -17,7 +17,7 @@ module Psych
if defined?(Ractor)
def dispatch
- Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache
+ @dispatch_cache ||= (Ractor.current[:Psych_Visitors_Visitor] ||= Visitor.dispatch_cache)
end
else
DISPATCH = dispatch_cache
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index ac6777aeb5..bf7c0bb8ca 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -509,9 +509,9 @@ module Psych
def emit_coder c, o
case c.type
when :scalar
- @emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, Nodes::Scalar::ANY
+ @emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, c.style
when :seq
- @emitter.start_sequence nil, c.tag, c.tag.nil?, Nodes::Sequence::BLOCK
+ @emitter.start_sequence nil, c.tag, c.tag.nil?, c.style
c.seq.each do |thing|
accept thing
end
diff --git a/ext/psych/yaml/loader.c b/ext/psych/yaml/loader.c
index 78b87e6f6b..bcf3aee8cb 100644
--- a/ext/psych/yaml/loader.c
+++ b/ext/psych/yaml/loader.c
@@ -541,4 +541,4 @@ yaml_parser_load_mapping_end(yaml_parser_t *parser, yaml_event_t *event,
(void)POP(parser, *ctx);
return 1;
-} \ No newline at end of file
+}
diff --git a/ext/psych/yaml/scanner.c b/ext/psych/yaml/scanner.c
index 6acee7d465..bb5d201274 100644
--- a/ext/psych/yaml/scanner.c
+++ b/ext/psych/yaml/scanner.c
@@ -273,7 +273,7 @@
* The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
* increase that precedes a block collection (cf. the INDENT token in Python).
* The token BLOCK-END denote indentation decrease that ends a block collection
- * (cf. the DEDENT token in Python). However YAML has some syntax pecularities
+ * (cf. the DEDENT token in Python). However YAML has some syntax peculiarities
* that makes detections of these tokens more complex.
*
* 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,
/* Check if we are at the end of the scalar. */
- /* Fix for crash unitialized value crash
+ /* Fix for crash uninitialized value crash
* Credit for the bug and input is to OSS Fuzz
* Credit for the fix to Alex Gaynor
*/
diff --git a/ext/psych/yaml/yaml.h b/ext/psych/yaml/yaml.h
index 4f84957d8f..f1b7bfde20 100644
--- a/ext/psych/yaml/yaml.h
+++ b/ext/psych/yaml/yaml.h
@@ -1095,7 +1095,7 @@ typedef struct yaml_parser_s {
yaml_error_type_t error;
/** Error description. */
const char *problem;
- /** The byte about which the problem occured. */
+ /** The byte about which the problem occurred. */
size_t problem_offset;
/** The problematic value (@c -1 is none). */
int problem_value;
@@ -1335,7 +1335,7 @@ yaml_parser_delete(yaml_parser_t *parser);
* Set a string input.
*
* Note that the @a input pointer must be valid while the @a parser object
- * exists. The application is responsible for destroing @a input after
+ * exists. The application is responsible for destroying @a input after
* destroying the @a parser.
*
* @param[in,out] parser A parser object.
@@ -1734,7 +1734,7 @@ typedef struct yaml_emitter_s {
size_t length;
/** Does the scalar contain line breaks? */
int multiline;
- /** Can the scalar be expessed in the flow plain style? */
+ /** Can the scalar be expressed in the flow plain style? */
int flow_plain_allowed;
/** Can the scalar be expressed in the block plain style? */
int block_plain_allowed;
@@ -1950,7 +1950,7 @@ yaml_emitter_close(yaml_emitter_t *emitter);
/**
* Emit a YAML document.
*
- * The documen object may be generated using the yaml_parser_load() function
+ * The document object may be generated using the yaml_parser_load() function
* or the yaml_document_initialize() function. The emitter takes the
* responsibility for the document object and destroys its content after
* it is emitted. The document object is destroyed even if the function fails.
diff --git a/ext/psych/yaml/yaml_private.h b/ext/psych/yaml/yaml_private.h
index 6c674de147..266a6bd3a7 100644
--- a/ext/psych/yaml/yaml_private.h
+++ b/ext/psych/yaml/yaml_private.h
@@ -2,7 +2,7 @@
#include RUBY_EXTCONF_H
#endif
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include "config.h"
#endif