Skip to content

SimpleHTTPRequestHandler incorrectly handles trailing escaped slash #134098

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

For path to directory which does not end with slash ("/"), SimpleHTTPRequestHandler returns status MOVED_PERMANENTLY with redirection to new path that ends with slash. Slashes can be percent-encoded, although this is not necessary. But the code that checks for the trailing slash does not take this into account (in two place).

Linked PRs

Activity

added
type-bugAn unexpected behavior, bug, or error
3.13bugs and security fixes
3.14bugs and security fixes
3.15new features, bugs and security fixes
on May 16, 2025
serhiy-storchaka

serhiy-storchaka commented on May 16, 2025

@serhiy-storchaka
MemberAuthor

Other effect of this bug -- a percent-encoded trailing slash is ignored after non-directory path (should return status NOT_FOUND).

added a commit that references this issue on May 16, 2025

pythongh-134098: Fix handling %-encoded trailing slash in SimpleHTTPR…

donBarbos

donBarbos commented on May 17, 2025

@donBarbos
Contributor

since you mentioned request handling, what do you think about making http.server accept "absolute form" as "request target"?
issue #132741

added a commit that references this issue on May 17, 2025

gh-134098: Fix handling %-encoded trailing slash in SimpleHTTPRequest…

2f1ecb3
added a commit that references this issue on May 17, 2025

pythongh-134098: Fix handling %-encoded trailing slash in SimpleHTTPR…

4 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    SimpleHTTPRequestHandler incorrectly handles trailing escaped slash · Issue #134098 · python/cpython

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant