[Python-bugs-list] [ python-Bugs-737202 ] CGIHTTPServer does not handle scripts in sub-dirs
SourceForge.net
noreply@sourceforge.net
Fri, 23 May 2003 06:21:46 -0700
Bugs item #737202, was opened at 2003-05-13 19:54
Message generated for change (Comment added) made by htgoebel
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=737202&group_id=5470
Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Hartmut Goebel (htgoebel)
Assigned to: Nobody/Anonymous (nobody)
Summary: CGIHTTPServer does not handle scripts in sub-dirs
Initial Comment:
CGIHTTPServer does not handle scripts in sub directoreis correctly:
When accessing eg. '/cgi-bin/scripts/bla', CGIHTTPServer returns
404 CGI script is not a plain file ('/cgi-bin/script')
This tracked down to CGIHTTPRequestHandler.run_cgi() containing
these lines:
i = rest.find('/')
if i >= 0:
script, rest = rest[:i], rest[i:]
else:
script, rest = rest, ''
scriptname = dir + '/' + script
This will move the dir-part of the 'rest' into 'script', but leave the
actual filename in 'rest'. The 'scriptname' thus does miss the filename.
I assume this should become simply:
script, rest = rest, ''
scriptname = dir + '/' + script
----------------------------------------------------------------------
>Comment By: Hartmut Goebel (htgoebel)
Date: 2003-05-23 15:21
Message:
Logged In: YES
user_id=376953
I rethought this: The reason for this type of split is to make it possible to
pass parameters as part of the URL, like Zope does.
So the snippet above should be changed to something like this:
i = 0
while 1:
# get the next path-element out of the url
i = rest.find('/', i)
if i >= 0:
script, rest = rest[:i], rest[i:]
else:
script, rest = rest, ''
scriptname = dir + '/' + script
scriptfile = self.translatepath(scriptname)
if os.isdir(scriptname):
# if scriptname is a directory, continue "walking" the url
continue
# scriptname is not a directory, stop "walking" the url
break
Patch is included.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=737202&group_id=5470