Unity/auto/yaml_helper.rb
Martyn Jago b44c2dd095 Fix broken YAML parsing on later Rubies with Psych >=4.0
YAML.load is now interpreted as YAML.safe_load, which breaks where the
YAML file contains aliases. If we can assume our yaml files are
trusted (since this a development tool), we can check for the presence
of YAML.unsafe_load and use it instead if it exists.
2022-05-27 15:08:11 +01:00

20 lines
509 B
Ruby

# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
require 'yaml'
module YamlHelper
def self.load(body)
YAML.respond_to?(:unsafe_load) ?
YAML.unsafe_load(body) : YAML.load(body)
end
def self.load_file(file)
body = File.read(file)
self.load(body)
end
end