Skip to content
Merged
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
10 changes: 5 additions & 5 deletions lib/rubygems/safe_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Gem
# Psych.safe_load

module SafeYAML
WHITELISTED_CLASSES = %w(
PERMITTED_CLASSES = %w(
Symbol
Time
Date
Expand All @@ -21,23 +21,23 @@ module SafeYAML
Syck::DefaultKey
).freeze

WHITELISTED_SYMBOLS = %w(
PERMITTED_SYMBOLS = %w(
development
runtime
).freeze

if ::YAML.respond_to? :safe_load
def self.safe_load input
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
::YAML.safe_load(input, whitelist_classes: WHITELISTED_CLASSES, whitelist_symbols: WHITELISTED_SYMBOLS, aliases: true)
::YAML.safe_load(input, permitted_classes: PERMITTED_CLASSES, permitted_symbols: PERMITTED_SYMBOLS, aliases: true)
else
::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true)
::YAML.safe_load(input, PERMITTED_CLASSES, PERMITTED_SYMBOLS, true)
end
end

def self.load input
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
::YAML.safe_load(input, whitelist_classes: [::Symbol])
::YAML.safe_load(input, permitted_classes: [::Symbol])
else
::YAML.safe_load(input, [::Symbol])
end
Expand Down