New submission from Glenn Linderman <[email protected]>:
I notice a deficiency in is_cgi: there is no documentation requiring
cgi_directories to be a single part, only that the initial value happens to be
a list of two directories, each of which have only a single part or level. The
description of is_cgi, however, only requires that the strings in
self.cgi_directories be prefixes of self.path, followed by "/" or end of
string. While it is not at all clear that being followed by end of string would
produce useful results, the description does allow for multiple parts in the
directory, but the implementation does not.
Consider a potential value in an overridden or augmented cgi_directories such
as '/subdomain/cgi-bin'. The current is_cgi wouldn't handle that.
Solution: replace the following is_cgi code (from current trunk):
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
with:
cln = len( collapsed_path )
found = False
for ix in self.cgi_directories:
ln = len( ix )
print('is_cgi: %d %d - %s - %s'
% ( ln, cln, ix, collapsed_path ))
if ln == cln and ix == collapsed_path:
self.cgi_info = ( ix, '')
found = True
break
elif ( ln < cln and collapsed_path[ ln ] == '/'
and collapsed_path.startswith( ix )):
self.cgi_info = ( ix, collapsed_path[ ln+1: ])
found = True
break
return found
----------
messages: 158158
nosy: v+python
priority: normal
severity: normal
status: open
title: is_cgi doesn't function as documented for cgi_directories
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com