-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
CGI HTTP server not running scripts from subdirectories #65522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Somewhere between Python 3.3 and 3.4, a bug was introduced that forbids the "http.server" module, working in CGI server mode, to run scripts residing in subdirectories. This will break existing software that relies on this feature. How to reproduce the bug:
print("""Content-type: text/plain CGI script executed successfully!
Content-type: text/plain CGI script executed successfully!
c:\Python33\python.exe -m http.server --cgi 8000 A request to "http://localhost:8000/cgi-bin/test/test.py" then produces the following in the HTTP server log: Serving HTTP on 0.0.0.0 port 8000 ...
C:\TMP>c:\Python34\python.exe -m http.server --cgi 8000 This _could_ be related to the change introduced by bpo-19435, although I am not sure. Tested with Windows XP SP3. |
Hi, I am curious about the fate of this issue -- whether it will be recognised as a bug (possibly a regression bug). Remember, it worked in Python 3.3 but stopped working in 3.4. |
The change in behavior is definitely caused by the changes for bpo-19435. The code added there does not work correctly if there are nested directories in the "cgi-bin" directory; for one thing, the initial os.path.isdir(scriptdir) test in run_cgi is failing because the path in nextdir is missing the dir component: it's testing /path/to/test instead of /path/to/cgi-bin/test. I didn't look further. Along with a fix, there should be a test for nested directories. And decide whether to fix the regression it presumably caused in the security branches as well. http://hg.python.org/cpython/file/d25ae22cc992/Lib/http/server.py#l1009 |
BTW, if someone is looking for an issue to help out with, this might be a good choice. |
Hi, I'm new. I wrote a test for nested directories under cgi-bin and got that to pass without failing the test added for 19435 by undoing most of the changes to run_cgi() but building path from the values in self.cgi_info. Thoughts? |
Zach, thanks for the patch and the test. Someone will review it in the coming days. In the meantime, if you haven't already, please review and submit the Python Contributor's Agreement: https://www.python.org/psf/contrib/contrib-form/ otherwise we won't be able to use your contribution. |
The fix and test look good to me. I'll apply it after Zach submits the contributor agreement. |
Done and done. |
New changeset d367ea865ea4 by Ned Deily in branch '2.7': New changeset 4de94641ba3e by Ned Deily in branch '3.2': New changeset b957f475e41e by Ned Deily in branch '3.3': New changeset 385f4406dc26 by Ned Deily in branch '3.4': New changeset 22e5a85ba840 by Ned Deily in branch 'default': |
Since the original changes for bpo-19435 were also applied to branches in security fix mode, the fix here is applied to them as well, with the exception of 3.1 which has subsequently moved to end-of-life status. Applied for release in 2.7.9, 3.2.6, 3.3.6, 3.4.2, and 3.5.0. Thanks again, Konstantin and Zach. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: