summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-17 19:21:46 +0900
committergit <svn-admin@ruby-lang.org>2023-04-19 06:56:19 +0000
commit30b3290f266609d502791ec5d2edb4885d89d462 (patch)
treede4d3106684a2bebc8532b957d3d4e4a172edca1 /lib
parentd0dc6179173a79635267bae951352d3dee5c5d13 (diff)
downloadruby-30b3290f266609d502791ec5d2edb4885d89d462.tar.gz
[rubygems/rubygems] Added guard condition for replacing __ variable in YAML keys
https://github.com/rubygems/rubygems/commit/e7d31405ea
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/yaml_serializer.rb4
-rw-r--r--lib/rubygems/config_file.rb14
2 files changed, 3 insertions, 15 deletions
diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb
index 09e77ab449..23dce9440b 100644
--- a/lib/bundler/yaml_serializer.rb
+++ b/lib/bundler/yaml_serializer.rb
@@ -50,7 +50,7 @@ module Bundler
$
/xo.freeze
- def load(str)
+ def load(str, is_rubygems: false)
res = {}
stack = [res]
last_hash = nil
@@ -58,7 +58,7 @@ module Bundler
str.split(/\r?\n/).each do |line|
if match = HASH_REGEX.match(line)
indent, key, quote, val = match.captures
- key = convert_to_backward_compatible_key(key)
+ key = convert_to_backward_compatible_key(key) unless is_rubygems
key = key[1..-1].to_sym if key.start_with?(":")
depth = indent.scan(/ /).length
if quote.empty? && val.empty?
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 97c11bd95d..2191a81184 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -351,20 +351,8 @@ if you believe they were disclosed to a third party.
return {} unless filename && !filename.empty? && File.exist?(filename)
begin
- content = Bundler::YAMLSerializer.load(File.read(filename))
+ content = Bundler::YAMLSerializer.load(File.read(filename), is_rubygems: true)
if content.is_a? Hash
- content.transform_keys! do |k|
- if k.match?(/__/)
- if k.is_a?(Symbol)
- k.to_s.gsub(/__/,".").to_sym
- else
- k.dup.gsub(/__/,".")
- end
- else
- k
- end
- end
-
content.transform_values! do |v|
if (v.is_a?(Hash) || v.is_a?(String)) && v.empty?
nil