mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Merge pull request #1085 from molobrakos/yaml_safe_load
use yaml safe loader
This commit is contained in:
commit
a0f6f3ac22
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user