relaton / relaton-bipm

MIT License
2 stars 0 forks source link

YAML.safe_load update #13

Closed opoudjis closed 2 years ago

opoudjis commented 2 years ago

https://makandracards.com/makandra/465149-ruby-the-yaml-safe_load-method-hides-some-pitfalls

Starting with psych 3.1.0 the safe_load api got more userfriendly by replacing positional arguments with keyword arguments:

if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
  ::YAML.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
else
  ::YAML.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true)
end

Ruby 3.1 appears to have upgraded its default version of psych. As a result, instances of YAML.safe_load with positional arguments now crash, as we have just updated our GitHub Actions to include Ruby 3.1.

There are instances of YAML.safe_load with positional arguments, by my reckoning, in:

lib/relaton_bipm/bipm_bibliography.rb: hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])

Please update as needed.