Skip to content

Commit

Permalink
Merge pull request #41 from ruby/dbm-psych-4-2nd
Browse files Browse the repository at this point in the history
Also use safe_load on YAML::Store
  • Loading branch information
hsbt authored Oct 16, 2024
2 parents 729575f + 5b39653 commit 8259763
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/yaml/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ def dump(table)
end

def load(content)
table = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(content) : YAML.load(content)
if table == false
table = if YAML.respond_to?(:safe_load)
if Psych::VERSION >= "3.1"
YAML.safe_load(content, permitted_classes: [Symbol])
else
YAML.safe_load(content, [Symbol])
end
else
YAML.load(content)
end
if table == false || table == nil
{}
else
table
Expand Down

0 comments on commit 8259763

Please sign in to comment.