Fix staticfiles 404 errors (#1005)

This commit is contained in:
Tom Christie 2020-07-20 13:05:55 +01:00 committed by GitHub
parent 6aa7d9e46e
commit 681450d658
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -140,11 +140,9 @@ class StaticFiles:
self, path: str
) -> typing.Tuple[str, typing.Optional[os.stat_result]]:
for directory in self.all_directories:
full_path = os.path.join(directory, path)
if (
os.path.commonprefix([os.path.realpath(full_path), directory])
!= directory
):
full_path = os.path.realpath(os.path.join(directory, path))
directory = os.path.realpath(directory)
if os.path.commonprefix([full_path, directory]) != directory:
# Don't allow misbehaving clients to break out of the static files directory.
continue
try: