Skip to content
Permalink
Browse files

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 1d507071e6a60523d8bda4ae401d309b3bcd27d7
Showing with 3 additions and 1 deletion.
  1. +3 −1 nikola/utils.py
@@ -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 {}
@@ -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

0 comments on commit 1d50707

Please sign in to comment.
You can’t perform that action at this time.