Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yaml.safe_load() instead of load() #281

Merged
merged 1 commit into from
Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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