Skip to content

Commit

Permalink
load YAML in tests with unsafe_load
Browse files Browse the repository at this point in the history
Starting from ruby3.1, the psych library uses safe_load underneath load
to read YAML. As Versionomy::Value is not in the whitelist of classes
permitted to be loaded two tests fails with the error
Psych::DisallowedClass: Tried to load unspecified class: Versionomy::Value
This change proposes to use `unsafe_load` as the YAML content to be
loaded is well controlled.
  • Loading branch information
boutil committed Nov 22, 2022
1 parent a940bca commit af459bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/tc_semver_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_marshal
def test_yaml
value_ = ::Versionomy.create([1, 9, 2, 'pre2'], :semver)
str_ = ::YAML.dump(value_)
value2_ = ::YAML.load(str_)
value2_ = ::YAML.unsafe_load(str_)
assert_equal(value_, value2_)
end

Expand Down
2 changes: 1 addition & 1 deletion test/tc_standard_misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_marshal
def test_yaml
value_ = ::Versionomy.create(:major => 1, :minor => 9, :tiny => 2, :release_type => :alpha, :alpha_version => 4)
str_ = ::YAML.dump(value_)
value2_ = ::YAML.load(str_)
value2_ = ::YAML.unsafe_load(str_)
assert_equal(value_, value2_)
end

Expand Down

0 comments on commit af459bd

Please sign in to comment.