diff --git a/Lib/http/server.py b/Lib/http/server.py --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -962,13 +962,14 @@ """ collapsed_path = _url_collapse_path(self.path) - dir_sep = collapsed_path.find('/', 1) - head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:] - if head in self.cgi_directories: - self.cgi_info = head, tail - return True - return False - + for cgi_path in self.cgi_directories: + if cgi_path == collapsed_path: + self.cgi_info = (cgi_path, '') + return True + elif (collapsed_path.startswith(cgi_path) + and collapsed_path[len(cgi_path)] == '/'): + self.cgi_info = cgi_path, collapsed_path[len(cgi_path) + 1:] + return True cgi_directories = ['/cgi-bin', '/htbin']