Black formatting

This commit is contained in:
Tom Christie 2018-07-12 17:07:20 +01:00
parent 0564e0c1b5
commit e3d090b359
2 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ class StaticFiles:
if scope["method"] not in ("GET", "HEAD"): if scope["method"] not in ("GET", "HEAD"):
return PlainTextResponse("Method not allowed", status_code=406) return PlainTextResponse("Method not allowed", status_code=406)
path = os.path.normpath(os.path.join(*scope["path"].split("/"))) path = os.path.normpath(os.path.join(*scope["path"].split("/")))
if path.startswith('..'): if path.startswith(".."):
return PlainTextResponse("Not found", status_code=404) return PlainTextResponse("Not found", status_code=404)
path = os.path.join(self.directory, path) path = os.path.join(self.directory, path)
if self.config_checked: if self.config_checked:

View File

@ -125,7 +125,7 @@ def test_staticfiles_config_check_occurs_only_once(tmpdir):
def test_staticfiles_prevents_breaking_out_of_directory(tmpdir): def test_staticfiles_prevents_breaking_out_of_directory(tmpdir):
directory = os.path.join(tmpdir, 'foo') directory = os.path.join(tmpdir, "foo")
os.mkdir(directory) os.mkdir(directory)
path = os.path.join(tmpdir, "example.txt") path = os.path.join(tmpdir, "example.txt")
@ -134,6 +134,6 @@ def test_staticfiles_prevents_breaking_out_of_directory(tmpdir):
app = StaticFiles(directory=directory) app = StaticFiles(directory=directory)
# We can't test this with 'requests', so we call the app directly here. # We can't test this with 'requests', so we call the app directly here.
response = app({'method': 'GET', 'path': '/../example.txt'}) response = app({"method": "GET", "path": "/../example.txt"})
assert response.status_code == 404 assert response.status_code == 404
assert response.body == b"Not found" assert response.body == b"Not found"