Issue #21323: Fix http.server to again handle scripts in CGI subdirectories,

broken by the fix for security issue #19435.  Patch by Zach Byrne.
This commit is contained in:
Ned Deily 2014-07-12 22:16:56 -07:00
commit 5d0d2e6ed6
4 changed files with 26 additions and 6 deletions

View file

@ -1000,16 +1000,16 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
def run_cgi(self):
"""Execute a CGI script."""
dir, rest = self.cgi_info
i = rest.find('/')
path = dir + '/' + rest
i = path.find('/', len(dir)+1)
while i >= 0:
nextdir = rest[:i]
nextrest = rest[i+1:]
nextdir = path[:i]
nextrest = path[i+1:]
scriptdir = self.translate_path(nextdir)
if os.path.isdir(scriptdir):
dir, rest = nextdir, nextrest
i = rest.find('/')
i = path.find('/', len(dir)+1)
else:
break