Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use safe_load for loading YAML
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 28, 2017
1 parent 2d25ac7 commit 1d50707
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nikola/utils.py
Expand Up @@ -2050,8 +2050,10 @@ def load_data(path):
"""Given path to a file, load data from it."""
ext = os.path.splitext(path)[-1]
loader = None
function = 'load'
if ext in {'.yml', '.yaml'}:
loader = yaml
function = 'safe_load'
if yaml is None:
req_missing(['yaml'], 'use YAML data files')
return {}
Expand All @@ -2065,7 +2067,7 @@ def load_data(path):
if loader is None:
return
with io.open(path, 'r', encoding='utf8') as inf:
return loader.load(inf)
return getattr(loader, function)(inf)


# see http://stackoverflow.com/a/2087433
Expand Down

0 comments on commit 1d50707

Please sign in to comment.