Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update friendlier terminology in Gem::SafeYAML #2463

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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