Skip to content

Commit

Permalink
Merge pull request #281 from fecgov/use-yaml-safe-load
Browse files Browse the repository at this point in the history
Use `yaml.safe_load()` instead of `load()`
  • Loading branch information
sloria committed Sep 8, 2018
2 parents 5ed0e91 + 56fe1c6 commit e9f10e2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ Contributors (chronological)
- Christina Long `@cvlong <https://github.com/cvlong>`_
- Felix Yan `@felixonmars <https://github.com/felixonmars>`_
- Guoli Lyu `@Guoli-Lyu <https://github.com/Guoli-Lyu>`_
- Laura Beaufort `@lbeaufort <https://github.com/lbeaufort>`_
2 changes: 1 addition & 1 deletion apispec/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def load_yaml_from_docstring(docstring):

yaml_string = '\n'.join(split_lines[cut_from:])
yaml_string = dedent(yaml_string)
return yaml.load(yaml_string) or {}
return yaml.safe_load(yaml_string) or {}


PATH_KEYS = set([
Expand Down
2 changes: 1 addition & 1 deletion docs/special_topics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Here is an example that includes a `Security Scheme Object <https://github.com/O
bearerFormat: JWT
"""
settings = yaml.load(OPENAPI_SPEC)
settings = yaml.safe_load(OPENAPI_SPEC)
# retrieve title, version, and openapi version
title = settings['info'].pop('title')
spec_version = settings['info'].pop('version')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_to_yaml(self, spec):
properties=self.properties,
enum=enum,
)
assert spec.to_dict() == yaml.load(spec.to_yaml())
assert spec.to_dict() == yaml.safe_load(spec.to_yaml())

class TestPath:
paths = {
Expand Down

0 comments on commit e9f10e2

Please sign in to comment.