use yaml safe loader

This commit is contained in:
Erik 2016-01-31 00:46:08 +01:00
parent b7722ec452
commit 4b253d17ba

View File

@ -19,7 +19,7 @@ def load_yaml(fname):
with open(fname, encoding='utf-8') as conf_file:
# If configuration file is empty YAML returns None
# We convert that to an empty dict
return yaml.load(conf_file) or {}
return yaml.safe_load(conf_file) or {}
except yaml.YAMLError:
error = 'Error reading YAML configuration file {}'.format(fname)
_LOGGER.exception(error)
@ -45,6 +45,6 @@ def _ordered_dict(loader, node):
return OrderedDict(loader.construct_pairs(node))
yaml.add_constructor('!include', _include_yaml)
yaml.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
_ordered_dict)
yaml.SafeLoader.add_constructor('!include', _include_yaml)
yaml.SafeLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
_ordered_dict)