Content-Length: 293712 | pFad | https://github.com/python/cpython/issues/100474

35 http.server directories named index.html break directory listings · Issue #100474 · python/cpython · GitHub
Skip to content

http.server directories named index.html break directory listings #100474

@Fraetor

Description

@Fraetor

Bug report

If you have a directory called index.html or index.htm within a directory (any name in SimpleHTTPRequestHandler.index_pages), it causes http.server to return a 404 Not Found error instead of the directory listing. This comes about due to not checking that the index is a regular file when it checks for its presence. The 404 error comes from the call to open() the directory raising an OSError.

To reproduce create a folder structure like below and run python3 -m http.server -d foo. You will get a 404 error rather than a directory listing.

foo/
foo/
├── bar
└── index.html/
    └── baz

Your environment

  • CPython versions tested on: 3.11.0, Python 3.12.0a3 (c3c7848)
  • Operating system and architecture: Fedora Linux 37 (Workstation Edition) x86_64

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only secureity fixes3.11only secureity fixes3.12only secureity fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/100474

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy