Skip to content

Commit e9f10e2

Browse files
authored
Merge pull request #281 from fecgov/use-yaml-safe-load
Use `yaml.safe_load()` instead of `load()`
2 parents 5ed0e91 + 56fe1c6 commit e9f10e2

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ Contributors (chronological)
5151
- Christina Long `@cvlong <https://github.com/cvlong>`_
5252
- Felix Yan `@felixonmars <https://github.com/felixonmars>`_
5353
- Guoli Lyu `@Guoli-Lyu <https://github.com/Guoli-Lyu>`_
54+
- Laura Beaufort `@lbeaufort <https://github.com/lbeaufort>`_

apispec/yaml_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def load_yaml_from_docstring(docstring):
4646

4747
yaml_string = '\n'.join(split_lines[cut_from:])
4848
yaml_string = dedent(yaml_string)
49-
return yaml.load(yaml_string) or {}
49+
return yaml.safe_load(yaml_string) or {}
5050

5151

5252
PATH_KEYS = set([

docs/special_topics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Here is an example that includes a `Security Scheme Object <https://github.com/O
8787
bearerFormat: JWT
8888
"""
8989
90-
settings = yaml.load(OPENAPI_SPEC)
90+
settings = yaml.safe_load(OPENAPI_SPEC)
9191
# retrieve title, version, and openapi version
9292
title = settings['info'].pop('title')
9393
spec_version = settings['info'].pop('version')

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_to_yaml(self, spec):
163163
properties=self.properties,
164164
enum=enum,
165165
)
166-
assert spec.to_dict() == yaml.load(spec.to_yaml())
166+
assert spec.to_dict() == yaml.safe_load(spec.to_yaml())
167167

168168
class TestPath:
169169
paths = {

0 commit comments

Comments
 (0)