summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-12-22 13:28:43 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-12-22 13:28:43 (GMT)
commitbbad84b41aa73a3cf4be1fe41ca5fde3814af9ca (patch)
tree82108f1e3e9f7ce797501473bc032ab75b5cb5ff /Lib
parent28cfe299be2c75343c9d4dae2dfe11a4124f7908 (diff)
downloadcpython-bbad84b41aa73a3cf4be1fe41ca5fde3814af9ca.zip
cpython-bbad84b41aa73a3cf4be1fe41ca5fde3814af9ca.tar.gz
cpython-bbad84b41aa73a3cf4be1fe41ca5fde3814af9ca.tar.bz2
[Bug #737202; fix from Titus Brown] Make CGIHTTPServer work for scripts in sub-directories
Diffstat (limited to 'Lib')
-rw-r--r--Lib/CGIHTTPServer.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
index 7a5c819..c119c9a 100644
--- a/Lib/CGIHTTPServer.py
+++ b/Lib/CGIHTTPServer.py
@@ -105,17 +105,36 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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):