diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2023-01-22 09:04:11 -0500 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2023-01-22 09:04:11 -0500 |
commit | 592a75a656a8575ae1791eb899f5bd5eb4f20352 (patch) | |
tree | c46f5924794c709cc2cd34531f1cd69719df8da0 /lib | |
parent | 2d472f5f20b588ed62c1fdea3da627dbd91bd73c (diff) | |
download | psych-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 'lib')
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 3185879..5149178 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/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 |