mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-29 11:14:27 +01:00
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.
This commit is contained in:
19
auto/yaml_helper.rb
Normal file
19
auto/yaml_helper.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# ==========================================
|
||||
# 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
|
||||
Reference in New Issue
Block a user