From 72e5573ec072f78ce5ccccf8056a8bf737f1183f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Fri, 19 Jul 2024 08:33:36 +0800 Subject: [PATCH] Fix: Resolve the issue where the directory itself being a symlink does not work. --- starlette/staticfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starlette/staticfiles.py b/starlette/staticfiles.py index 7498c3011..746e740e0 100644 --- a/starlette/staticfiles.py +++ b/starlette/staticfiles.py @@ -155,7 +155,7 @@ def lookup_path(self, path: str) -> tuple[str, os.stat_result | None]: full_path = os.path.abspath(joined_path) else: full_path = os.path.realpath(joined_path) - directory = os.path.realpath(directory) + directory = os.path.realpath(directory) if os.path.commonpath([full_path, directory]) != directory: # Don't allow misbehaving clients to break out of the static files # directory.