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

Skip to content

Commit d05853d

Browse files
committed
merge - fix the incorrect changes made for PATH_INFO value - Issue10484
2 parents eba2428 + dbb369d commit d05853d

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
@@ -865,14 +865,7 @@ def _url_collapse_path_split(path):
865865
# Filter out blank non trailing parts before consuming the '..'.
866866
path_parts = [part for part in path_parts[:-1] if part] + path_parts[-1:]
867867
if path_parts:
868-
# Special case for CGI's for PATH_INFO
869-
if path.startswith('/cgi-bin') or path.startswith('/htbin'):
870-
tail_part = []
871-
while path_parts[-1] not in ('cgi-bin','htbin'):
872-
tail_part.insert(0,path_parts.pop())
873-
tail_part = "/".join(tail_part)
874-
else:
875-
tail_part = path_parts.pop()
868+
tail_part = path_parts.pop()
876869
else:
877870
tail_part = ''
878871
head_parts = []
@@ -963,8 +956,11 @@ def is_cgi(self):
963956
"""
964957

965958
splitpath = _url_collapse_path_split(self.path)
966-
if splitpath[0] in self.cgi_directories:
967-
self.cgi_info = splitpath
959+
joined_path = '/'.join(splitpath)
960+
dir_sep = joined_path.find('/',1)
961+
head, tail = joined_path[:dir_sep], joined_path[dir_sep+1:]
962+
if head in self.cgi_directories:
963+
self.cgi_info = head, tail
968964
return True
969965
return False
970966

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)