[Python-checkins] r53140 - in python/branches/release25-maint: Lib/CGIHTTPServer.py Misc/NEWS
andrew.kuchling
python-checkins at python.org
Fri Dec 22 14:28:44 CET 2006
Author: andrew.kuchling
Date: Fri Dec 22 14:28:43 2006
New Revision: 53140
Modified:
python/branches/release25-maint/Lib/CGIHTTPServer.py
python/branches/release25-maint/Misc/NEWS
Log:
[Bug #737202; fix from Titus Brown] Make CGIHTTPServer work for scripts in sub-directories
Modified: python/branches/release25-maint/Lib/CGIHTTPServer.py
==============================================================================
--- python/branches/release25-maint/Lib/CGIHTTPServer.py (original)
+++ python/branches/release25-maint/Lib/CGIHTTPServer.py Fri Dec 22 14:28:43 2006
@@ -105,17 +105,36 @@
def run_cgi(self):
"""Execute a CGI script."""
+ path = self.path
dir, rest = self.cgi_info
+
+ i = path.find('/', len(dir) + 1)
+ while i >= 0:
+ nextdir = path[:i]
+ nextrest = path[i+1:]
+
+ scriptdir = self.translate_path(nextdir)
+ if os.path.isdir(scriptdir):
+ dir, rest = nextdir, nextrest
+ i = path.find('/', len(dir) + 1)
+ else:
+ break
+
+ # find an explicit query string, if present.
i = rest.rfind('?')
if i >= 0:
rest, query = rest[:i], rest[i+1:]
else:
query = ''
+
+ # dissect the part after the directory name into a script name &
+ # a possible additional path, to be stored in PATH_INFO.
i = rest.find('/')
if i >= 0:
script, rest = rest[:i], rest[i:]
else:
script, rest = rest, ''
+
scriptname = dir + '/' + script
scriptfile = self.translate_path(scriptname)
if not os.path.exists(scriptfile):
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Fri Dec 22 14:28:43 2006
@@ -122,6 +122,9 @@
Library
-------
+- Bug #737202: Make CGIHTTPServer work for scripts in subdirectories.
+ Fix by Titus Brown.
+
- Patch #1608267: fix a race condition in os.makedirs() is the directory
to be created is already there.
More information about the Python-checkins
mailing list