summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2023-01-22 09:04:11 -0500
committerJean Boussier <jean.boussier@gmail.com>2023-01-22 09:04:11 -0500
commit592a75a656a8575ae1791eb899f5bd5eb4f20352 (patch)
treec46f5924794c709cc2cd34531f1cd69719df8da0 /test
parent2d472f5f20b588ed62c1fdea3da627dbd91bd73c (diff)
downloadpsych-592a75a656a8575ae1791eb899f5bd5eb4f20352.tar.gz
Fix RestrictedYAMLTree allowing the Symbol class should allow all symbols
Ref: https://github.com/ruby/psych/pull/495 That's how it works for `safe_load`: ```ruby >> YAML.safe_load(':foo', permitted_classes: [Symbol]) => :foo ``` So `safe_dump` should mirror that.
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_psych.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 1abd69c..c977e79 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -419,12 +419,15 @@ eoyml
end
def test_safe_dump_symbols
+ assert_equal Psych.dump(:foo), Psych.safe_dump(:foo, permitted_classes: [Symbol])
+ assert_equal Psych.dump(:foo), Psych.safe_dump(:foo, permitted_symbols: [:foo])
+
error = assert_raise Psych::DisallowedClass do
- Psych.safe_dump(:foo, permitted_classes: [Symbol])
+ Psych.safe_dump(:foo)
end
assert_equal "Tried to dump unspecified class: Symbol(:foo)", error.message
- assert_match(/\A--- :foo\n(?:\.\.\.\n)?\z/, Psych.safe_dump(:foo, permitted_classes: [Symbol], permitted_symbols: [:foo]))
+ assert_match(/\A--- :foo\n(?:\.\.\.\n)?\z/, Psych.safe_dump(:foo, permitted_symbols: [:foo]))
end
def test_safe_dump_aliases