summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2023-01-22 09:04:11 -0500
committergit <svn-admin@ruby-lang.org>2023-01-23 02:07:23 +0000
commit8fded5f5d12be958ca803627a541e5a5d9323586 (patch)
tree0bb999a807d574b220abe9080ed5deadf58df37e /test/psych
parentd623210811354aec6740d594e41d7aeccbc00da8 (diff)
downloadruby-8fded5f5d12be958ca803627a541e5a5d9323586.tar.gz
[ruby/psych] 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. https://github.com/ruby/psych/commit/592a75a656
Diffstat (limited to 'test/psych')
-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 1abd69ceca..c977e799e3 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