Skip to content

bpo-38863: Fix a bug of is_cgi() in http.server#17292

Closed
kkangshawn wants to merge 1 commit into
python:masterfrom
kkangshawn:fix-issue-38863
Closed

bpo-38863: Fix a bug of is_cgi() in http.server#17292
kkangshawn wants to merge 1 commit into
python:masterfrom
kkangshawn:fix-issue-38863

Conversation

@kkangshawn

@kkangshawn kkangshawn commented Nov 20, 2019

Copy link
Copy Markdown
Contributor

is_cgi() function of http.server library does not correctly separate
given path for cgi script into a directory and a file part. is_cgi() in
CGIHTTPRequestHandler class separates given path into (dir, rest) then
checks if dir is in cgi_directories. However, it divides based on the
first seen '/', multi-level directories like /sub/dir/cgi-bin/hello.py
is divided into head=/sub, rest=dir/cgi-bin/hello.py then check whether
'/sub' exists in cgi_directories = [..., '/sub/dir/cgi-bin'].
If the function divides by last seen '/', it works correctly as
head=/sub/dir/cgi-bin, rest=hello.py

Signed-off-by: Siwon Kang kkangshawn@gmail.com

https://bugs.python.org/issue38863

is_cgi() function of http.server library does not correctly separate
given path for cgi script into a directory and a file part. is_cgi() in
CGIHTTPRequestHandler class separates given path into (dir, rest) then
checks if dir is in cgi_directories. However, it divides based on the
first seen '/', multi-level directories like /sub/dir/cgi-bin/hello.py
is divided into head=/sub, rest=dir/cgi-bin/hello.py then check whether
'/sub' exists in cgi_directories = [..., '/sub/dir/cgi-bin'].
If the function divides by last seen '/', it works correctly as
head=/sub/dir/cgi-bin, rest=hello.py

Signed-off-by: Siwon Kang <kkangshawn@gmail.com>
@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@kkangshawn

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants