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:06:26 -07:00
parent 314dc126ce
commit 915a30fb0d
4 changed files with 25 additions and 5 deletions

View file

@ -969,16 +969,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