[ python-Bugs-737202 ] CGIHTTPServer does not handle scripts in sub-dirs

SourceForge.net noreply at sourceforge.net
Sun Jan 16 16:12:00 CET 2005


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: 2005-01-16 16:11

Message:
Logged In: YES 
user_id=376953

Encloded please find a testcase.

I've checkt it with 2.3.3.

Buf should still persist in 2.3.4 and 2.4. I've checked the
CVS diffs and there is no change which would solve it.

----------------------------------------------------------------------

Comment By: Facundo Batista (facundobatista)
Date: 2005-01-15 19:42

Message:
Logged In: YES 
user_id=752496

Both bugs are for the same problem, keeping this alive
(because it has the patch), closing  the other as Duplicate.

Regarding the patch, the actual code has something very
similar to it, so maybe the bug is already fixed...

----------------------------------------------------------------------

Comment By: Facundo Batista (facundobatista)
Date: 2005-01-15 19:42

Message:
Logged In: YES 
user_id=752496

Please, could you verify if this problem persists in Python 2.3.4
or 2.4?

If yes, in which version? Can you provide a test case?

If the problem is solved, from which version?

Note that if you fail to answer in one month, I'll close this bug
as "Won't fix".

Thank you! 

.    Facundo

----------------------------------------------------------------------

Comment By: Titus Brown (titus)
Date: 2004-12-19 07:20

Message:
Logged In: YES 
user_id=23486

same as bug 778804, assigned to esr.

----------------------------------------------------------------------

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


More information about the Python-bugs-list mailing list