File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -865,7 +865,14 @@ 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- tail_part = path_parts .pop ()
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 ()
869876 else :
870877 tail_part = ''
871878 head_parts = []
Original file line number Diff line number Diff line change @@ -377,6 +377,7 @@ 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' ),
380381 'a' : ('/' , 'a' ),
381382 '/a' : ('/' , 'a' ),
382383 '//a' : ('/' , 'a' ),
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ Core and Builtins
2424Library
2525-------
2626
27+ - Issue #10484: Fix the CGIHTTPServer's PATH_INFO handling problem.
28+
2729- Issue #11199: Fix the with urllib which hangs on particular ftp urls.
2830
2931- Issue #14222: Use the new time.steady() function instead of time.time() for
You can’t perform that action at this time.
0 commit comments