vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb in bolt-0.23.0 vs vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb in bolt-0.24.0
- old
+ new
@@ -44,22 +44,21 @@
def load_data_hash(options, context)
path = options['path']
context.cached_file_data(path) do |content|
begin
- data = YAML.load(content, path)
+ data = Puppet::Util::Yaml.safe_load(content, [Symbol], path)
if data.is_a?(Hash)
Puppet::Pops::Lookup::HieraConfig.symkeys_to_string(data)
else
msg = _("%{path}: file does not contain a valid yaml hash") % { path: path }
raise Puppet::DataBinding::LookupError, msg if Puppet[:strict] == :error && data != false
Puppet.warning(msg)
{}
end
- rescue YAML::SyntaxError => ex
- # Psych errors includes the absolute path to the file, so no need to add that
- # to the message
- raise Puppet::DataBinding::LookupError, "Unable to parse #{ex.message}"
+ rescue Puppet::Util::Yaml::YamlLoadError => ex
+ # YamlLoadErrors include the absolute path to the file, so no need to add that
+ raise Puppet::DataBinding::LookupError, _("Unable to parse %{message}") % { message: ex.message }
end
end
end
def decrypt_value(value, context, options)