Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rubygems/commands/owner_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def show_owners(name)
end

with_response response do |resp|
owners = Gem::SafeYAML.load clean_text(resp.body)
owners = Gem::SafeYAML.safe_load clean_text(resp.body)

say "Owners for gem: #{name}"
owners.each do |owner|
Expand Down
17 changes: 2 additions & 15 deletions lib/rubygems/safe_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,8 @@ def self.safe_load(input)
end
end

def self.load(input)
if Gem.use_psych?
if ::Psych.respond_to?(:unsafe_load)
::Psych.unsafe_load(input)
else
::Psych.load(input)
end
else
Gem::YAMLSerializer.load(
input,
permitted_classes: PERMITTED_CLASSES,
permitted_symbols: PERMITTED_SYMBOLS,
aliases: aliases_enabled?
)
end
class << self
alias_method :load, :safe_load
end
end
end
4 changes: 2 additions & 2 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,10 @@ def write_dummy_extconf(gem_name)
end

##
# Load a YAML string, the psych 3 way
# Load a YAML string using the safe loader with gem-spec permitted classes.

def load_yaml(yaml)
Gem::SafeYAML.load(yaml)
Gem::SafeYAML.safe_load(yaml)
end

##
Expand Down
4 changes: 0 additions & 4 deletions test/rubygems/test_gem_commands_owner_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def test_show_owners
def test_show_owners_dont_load_objects
Gem.load_yaml

# Gem::SafeYAML.load uses Psych.unsafe_load when Psych is enabled,
# which does not restrict classes. Only YAMLSerializer restricts object tags.
pend "Gem::SafeYAML.load uses Psych.unsafe_load which does not restrict classes" if Gem.use_psych?

response = <<EOF
---
- email: !ruby/object:Object {}
Expand Down
Loading