[rubygems/rubygems] warn message when RubyGems handle invalid yaml like 'invalid: foo: bar'

https://github.com/rubygems/rubygems/commit/b8d0c25b7e
This commit is contained in:
Hiroshi SHIBATA 2023-04-19 18:41:53 +09:00 committed by git
parent dbcdac00e6
commit 4bb0e01da2

View File

@ -347,7 +347,13 @@ if you believe they were disclosed to a third party.
return {} unless filename && !filename.empty? && File.exist?(filename)
begin
return self.class.load_with_rubygems_config_hash(File.read(filename))
config = self.class.load_with_rubygems_config_hash(File.read(filename))
if config.keys.any? { |k| k.include?(":") }
warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
return {}
else
return config
end
rescue *yaml_errors => e
warn "Failed to load #{filename}, #{e}"
rescue Errno::EACCES