Skip to content

Commit

Permalink
Change all instances of FullLoader to SafeLoader (#1285)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahellison committed Jul 3, 2021
1 parent 2648413 commit 9e31534
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions features/steps/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import toml
import yaml
from yaml.loader import FullLoader
from yaml.loader import SafeLoader


import jrnl.time
Expand Down Expand Up @@ -409,7 +409,7 @@ def run(context, command, text=""):

if "config_path" in context and context.config_path is not None:
with open(context.config_path) as f:
context.jrnl_config = yaml.load(f, Loader=yaml.FullLoader)
context.jrnl_config = yaml.load(f, Loader=yaml.SafeLoader)
else:
context.jrnl_config = None

Expand All @@ -418,7 +418,7 @@ def run(context, command, text=""):
command = command.format(cache_dir=cache_dir)
if "config_path" in context and context.config_path is not None:
with open(context.config_path, "r") as f:
cfg = yaml.load(f, Loader=FullLoader)
cfg = yaml.load(f, Loader=SafeLoader)
context.jrnl_config = cfg

args = split_args(command)
Expand Down Expand Up @@ -675,7 +675,7 @@ def check_journal_entries(context, number, journal_name="default"):
@when("the journal directory is listed")
def list_journal_directory(context, journal="default"):
with open(context.config_path) as config_file:
configuration = yaml.load(config_file, Loader=yaml.FullLoader)
configuration = yaml.load(config_file, Loader=yaml.SafeLoader)
journal_path = configuration["journals"][journal]
for root, dirnames, f in os.walk(journal_path):
for file in f:
Expand Down
4 changes: 2 additions & 2 deletions jrnl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def make_yaml_valid_dict(input: list) -> dict:

# yaml compatible strings are of the form Key:Value
yamlstr = YAML_SEPARATOR.join(input)
runtime_modifications = yaml.load(yamlstr, Loader=yaml.FullLoader)
runtime_modifications = yaml.load(yamlstr, Loader=yaml.SafeLoader)

return runtime_modifications

Expand Down Expand Up @@ -140,7 +140,7 @@ def verify_config_colors(config):
def load_config(config_path):
"""Tries to load a config file from YAML."""
with open(config_path) as f:
return yaml.load(f, Loader=yaml.FullLoader)
return yaml.load(f, Loader=yaml.SafeLoader)


def is_config_json(config_path):
Expand Down
2 changes: 1 addition & 1 deletion jrnl/plugins/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, template):
def from_file(cls, filename):
with open(filename) as f:
front_matter, body = f.read().strip("-\n").split("---", 2)
front_matter = yaml.load(front_matter, Loader=yaml.FullLoader)
front_matter = yaml.load(front_matter, Loader=yaml.SafeLoader)
template = cls(body)
template.__dict__.update(front_matter)
return template
Expand Down

0 comments on commit 9e31534

Please sign in to comment.