Skip to content

Commit

Permalink
Update Gem::SafeYAML
Browse files Browse the repository at this point in the history
use better terminology
  • Loading branch information
Juanito Fatas committed Nov 9, 2018
1 parent d43e4d0 commit 225fd4a
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 225fd4a

Please sign in to comment.