diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-04-19 18:41:53 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-04-20 01:57:17 +0000 |
commit | 4bb0e01da2083bd537444ce7f27f3e1cdfa23712 (patch) | |
tree | 3816fcec33168572e9613c0a4461d6a637414fd0 /lib/rubygems | |
parent | dbcdac00e6b9b9b72c0679e54d2ecef02a9cf3bc (diff) |
[rubygems/rubygems] warn message when RubyGems handle invalid yaml like 'invalid: foo: bar'
https://github.com/rubygems/rubygems/commit/b8d0c25b7e
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/config_file.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb index 42e408f254..1261e1e1a6 100644 --- a/lib/rubygems/config_file.rb +++ b/lib/rubygems/config_file.rb @@ -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 |