Skip to content

Commit

Permalink
Support Psych 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
playerace committed Oct 20, 2023
1 parent c115ed3 commit 3b9798d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def self.yaml_load(yaml)
rescue LoadError
if YAML.respond_to?(:safe_load)
def self.yaml_load(yaml)
YAML.safe_load(yaml)
# https://github.com/rails/rails/blob/v6.1.7.6/activerecord/lib/active_record/coders/yaml_column.rb#L50-L56
if ActiveRecord::Base.use_yaml_unsafe_load
YAML.unsafe_load(yaml)
elsif YAML.method(:safe_load).parameters.include?([:key, :permitted_classes])
YAML.safe_load(yaml, permitted_classes: ActiveRecord::Base.yaml_column_permitted_classes, aliases: true)
else
YAML.safe_load(yaml, ActiveRecord::Base.yaml_column_permitted_classes, [], true)
end
end
else
raise LoadError.new "Safe-loading of YAML is not available. Please install 'safe_yaml' or install Psych 2.0+"
Expand Down

0 comments on commit 3b9798d

Please sign in to comment.