summaryrefslogtreecommitdiff
path: root/ext
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 /ext
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 'ext')
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 31858798e4..51491783c3 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -568,7 +568,7 @@ module Psych
raise BadAlias, "Tried to dump an aliased object"
end
- unless @permitted_classes[target.class]
+ unless Symbol === target || @permitted_classes[target.class]
raise DisallowedClass.new('dump', target.class.name || target.class.inspect)
end
@@ -576,7 +576,7 @@ module Psych
end
def visit_Symbol sym
- unless @permitted_symbols[sym]
+ unless @permitted_classes[Symbol] || @permitted_symbols[sym]
raise DisallowedClass.new('dump', "Symbol(#{sym.inspect})")
end