Description: Add support for Psych 4.x YAML library, shipped with ruby3.1
From: Jon Pascoe <jon.pascoe@me.com>
Date: Wed, 2 Mar 2022 18:31:23 +0000
Origin: upstream,https://github.com/ice-cube-ruby/ice_cube/commit/6b97e77c106cd6662cb7292a5f59b01e4ccaedc6
Bug-Debian: https://bugs.debian.org/1019632
Reviewed-By: Cédric Boutillier <boutil@debian.org>

--- a/spec/examples/serialization_spec.rb
+++ b/spec/examples/serialization_spec.rb
@@ -17,7 +17,7 @@
       let(:start_time) { Time.now.in_time_zone("America/Vancouver") }
 
       it "serializes time as a Hash" do
-        hash = YAML.load(yaml)
+        hash = YAML.safe_load(yaml, permitted_classes: [Symbol, Time])
         expect(hash[:start_time][:time]).to eq start_time.utc
         expect(hash[:start_time][:zone]).to eq "America/Vancouver"
       end
--- a/spec/examples/to_yaml_spec.rb
+++ b/spec/examples/to_yaml_spec.rb
@@ -312,7 +312,8 @@
 
       symbol_yaml = Schedule.from_hash(symbol_data).to_yaml
       string_yaml = Schedule.from_hash(string_data).to_yaml
-      expect(YAML.load(symbol_yaml)).to eq(YAML.load(string_yaml))
+      expect(YAML.safe_load(symbol_yaml, permitted_classes: [Symbol, Time]))
+        .to eq(YAML.safe_load(string_yaml, permitted_classes: [Symbol, Time]))
     end
 
     it 'should raise an ArgumentError when trying to deserialize an invalid rule type' do
--- a/lib/ice_cube/parsers/yaml_parser.rb
+++ b/lib/ice_cube/parsers/yaml_parser.rb
@@ -8,7 +8,7 @@
     attr_reader :hash
 
     def initialize(yaml)
-      @hash = YAML::load(yaml)
+      @hash = YAML.safe_load(yaml, permitted_classes: [Date, Symbol, Time], aliases: true)
       yaml.match SERIALIZED_START do |match|
         start_time = hash[:start_time] || hash[:start_date]
         TimeUtil.restore_deserialized_offset start_time, match[:tz]
--- a/lib/ice_cube/rule.rb
+++ b/lib/ice_cube/rule.rb
@@ -44,7 +44,7 @@
 
     # From yaml
     def self.from_yaml(yaml)
-      from_hash YAML::load(yaml)
+      from_hash YAML.safe_load(yaml, permitted_classes: [Date, Symbol, Time])
     end
 
     def to_hash
--- a/spec/examples/active_support_spec.rb
+++ b/spec/examples/active_support_spec.rb
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../spec_helper'
+require 'active_support'
 require 'active_support/time'
 require 'active_support/version'
 require 'tzinfo' if ActiveSupport::VERSION::MAJOR == 3
