Skip to content

Commit 5e6de36

Browse files
committed
Fix Interscript for new Psych releases
Psych (the Ruby YAML library) has changed semantics of `YAML.load` frim being `unsafe_load` by default, to being `safe_load`. `safe_load` differs from `unsafe_load` by whitelisting a number of classes. We rely on the old behavior, as some maps contain date in the Date format and Date is not in a whitelisted set. Older versions of Psych may not support a `unsafe_load` method and those versions are chosen for certain older Ruby versions that we support. The question of safety in this case is secondary, since the maps are already executed as Ruby code.
1 parent d7c8e16 commit 5e6de36

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/interscript/dsl.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ def self.parse(map_name, reverse: true)
7676
yaml = if yaml =~ /\A\s*\z/
7777
{}
7878
else
79-
YAML.load(yaml, filename: exc_fname)
79+
unsafe_load = if YAML.respond_to? :unsafe_load
80+
:unsafe_load
81+
else
82+
:load
83+
end
84+
YAML.public_send(unsafe_load, yaml, filename: exc_fname)
8085
end
8186

8287
md = Interscript::DSL::Metadata.new(yaml: true, map_name: map_name, library: library) do

0 commit comments

Comments
 (0)