ruby-changes:66234
From: Yusuke <ko1@a...>
Date: Mon, 17 May 2021 15:43:53 +0900 (JST)
Subject: [ruby-changes:66234] 008a63c477 (master): Revert "Use YAML.unsafe_load instead of YAML.load."
https://git.ruby-lang.org/ruby.git/commit/?id=008a63c477 From 008a63c477c35ff72344370005029fc73c5ae6eb Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Mon, 17 May 2021 15:32:41 +0900 Subject: Revert "Use YAML.unsafe_load instead of YAML.load." This reverts commit a0e97b0e2e4314a0815d09beb825e38f234778da. --- spec/mspec/lib/mspec/matchers/match_yaml.rb | 2 +- spec/ruby/library/yaml/load_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/mspec/lib/mspec/matchers/match_yaml.rb b/spec/mspec/lib/mspec/matchers/match_yaml.rb index 614020e..920d85a 100644 --- a/spec/mspec/lib/mspec/matchers/match_yaml.rb +++ b/spec/mspec/lib/mspec/matchers/match_yaml.rb @@ -30,7 +30,7 @@ class MatchYAMLMatcher https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/match_yaml.rb#L30 def valid_yaml?(obj) require 'yaml' begin - YAML.unsafe_load(obj) + YAML.load(obj) rescue false else diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb index f375577..0b6bef2 100644 --- a/spec/ruby/library/yaml/load_spec.rb +++ b/spec/ruby/library/yaml/load_spec.rb @@ -99,7 +99,7 @@ describe "YAML.load" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/load_spec.rb#L99 Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ] } - YAML.unsafe_load($complex_key_1).should == expected + YAML.load($complex_key_1).should == expected end it "loads a symbol key that contains spaces" do @@ -110,26 +110,26 @@ describe "YAML.load" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/yaml/load_spec.rb#L110 describe "with iso8601 timestamp" do it "computes the microseconds" do - [ [YAML.unsafe_load("2011-03-22t23:32:11.2233+01:00"), 223300], - [YAML.unsafe_load("2011-03-22t23:32:11.0099+01:00"), 9900], - [YAML.unsafe_load("2011-03-22t23:32:11.000076+01:00"), 76] + [ [YAML.load("2011-03-22t23:32:11.2233+01:00"), 223300], + [YAML.load("2011-03-22t23:32:11.0099+01:00"), 9900], + [YAML.load("2011-03-22t23:32:11.000076+01:00"), 76] ].should be_computed_by(:usec) end it "rounds values smaller than 1 usec to 0 " do - YAML.unsafe_load("2011-03-22t23:32:11.000000342222+01:00").usec.should == 0 + YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec.should == 0 end end it "loads an OpenStruct" do require "ostruct" os = OpenStruct.new("age" => 20, "name" => "John") - loaded = YAML.unsafe_load("--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n") + loaded = YAML.load("--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n") loaded.should == os end it "loads a File but raise an error when used as it is uninitialized" do - loaded = YAML.unsafe_load("--- !ruby/object:File {}\n") + loaded = YAML.load("--- !ruby/object:File {}\n") -> { loaded.read(1) }.should raise_error(IOError) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/