Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dbb369d

Browse files
committed
3.2- fix the incorrect changes made for PATH_INFO value - Issue10484
1 parent 935b629 commit dbb369d

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

Lib/http/server.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -850,14 +850,7 @@ def _url_collapse_path_split(path):
850850
# Filter out blank non trailing parts before consuming the '..'.
851851
path_parts = [part for part in path_parts[:-1] if part] + path_parts[-1:]
852852
if path_parts:
853-
# Special case for CGI's for PATH_INFO
854-
if path.startswith('/cgi-bin') or path.startswith('/htbin'):
855-
tail_part = []
856-
while path_parts[-1] not in ('cgi-bin','htbin'):
857-
tail_part.insert(0,path_parts.pop())
858-
tail_part = "/".join(tail_part)
859-
else:
860-
tail_part = path_parts.pop()
853+
tail_part = path_parts.pop()
861854
else:
862855
tail_part = ''
863856
head_parts = []
@@ -952,8 +945,11 @@ def is_cgi(self):
952945
"""
953946

954947
splitpath = _url_collapse_path_split(self.path)
955-
if splitpath[0] in self.cgi_directories:
956-
self.cgi_info = splitpath
948+
joined_path = '/'.join(splitpath)
949+
dir_sep = joined_path.find('/',1)
950+
head, tail = joined_path[:dir_sep], joined_path[dir_sep+1:]
951+
if head in self.cgi_directories:
952+
self.cgi_info = head, tail
957953
return True
958954
return False
959955

Lib/test/test_httpservers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ def test_url_collapse_path_split(self):
377377
'/.//': ('/', ''),
378378
'cgi-bin/file1.py': ('/cgi-bin', 'file1.py'),
379379
'/cgi-bin/file1.py': ('/cgi-bin', 'file1.py'),
380-
'/cgi-bin/file1.py/PATH-INFO': ('/cgi-bin', 'file1.py/PATH-INFO'),
381380
'a': ('/', 'a'),
382381
'/a': ('/', 'a'),
383382
'//a': ('/', 'a'),

0 commit comments

Comments
 (0)