gh-100474: Fix handling of dirs named index.html in http.server (GH-100475)

If you had a directory called index.html or index.htm within a directory, it would cause http.server to return a 404 Not Found error instead of the directory listing. This came about due to not checking that the index was a regular file.

I have also added a test case for this situation.

Automerge-Triggered-By: GH:merwok
This commit is contained in:
James Frost 2022-12-24 18:28:59 +00:00 committed by GitHub
parent 00afa5066b
commit 46e6a28308
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -711,7 +711,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
return None
for index in self.index_pages:
index = os.path.join(path, index)
if os.path.exists(index):
if os.path.isfile(index):
path = index
break
else: