summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/psych/lib/psych.rb2
-rw-r--r--test/psych/test_stream.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 1c9dea5bba..0c158c9ff3 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -671,7 +671,7 @@ module Psych
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
+ safe_load(stream.to_yaml, permitted_classes: permitted_classes, aliases: aliases)
end
if block_given?
diff --git a/test/psych/test_stream.rb b/test/psych/test_stream.rb
index 9b71c6d996..ae940d1ee4 100644
--- a/test/psych/test_stream.rb
+++ b/test/psych/test_stream.rb
@@ -54,6 +54,14 @@ module Psych
assert_equal %w{ foo bar }, list
end
+ def test_safe_load_stream_yields_documents
+ list = []
+ Psych.safe_load_stream("--- foo\n...\n--- bar") do |ruby|
+ list << ruby
+ end
+ assert_equal %w{ foo bar }, list
+ end
+
def test_load_stream_break
list = []
Psych.load_stream("--- foo\n...\n--- `") do |ruby|