summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrenGitHub <[email protected]>2025-04-29 05:57:48 +0300
committergit <[email protected]>2025-05-09 17:53:17 +0000
commitf0e2a41d4bacd4ad37843b662194f128737407cf (patch)
treed26d52617a67e9afb5832db479c1439c9a5b8836
parentd69319304f111a9c1c9fac8d92460547b8749610 (diff)
[ruby/psych] fixed bugs from testing
https://github.com/ruby/psych/commit/e954f96639
-rw-r--r--ext/psych/lib/psych.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 64637b97f7..1c9dea5bba 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -668,8 +668,17 @@ module Psych
# list # => ['foo', 'bar']
#
def self.safe_load_stream yaml, filename: nil, permitted_classes: [], aliases: false
- parse_stream(yaml, filename: filename).children.map do |child|
- safe_load(child.to_yaml, permitted_classes, aliases: aliases)
+ documents = parse_stream(yaml, filename: filename).children.map do |child|
+ stream = Psych::Nodes::Stream.new
+ stream.children << child
+ safe_load stream.to_yaml, permitted_classes: permitted_classes, aliases: aliases
+ end
+
+ if block_given?
+ documents.each { |doc| yield doc }
+ nil
+ else
+ documents
end
end