Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14565] is_cgi doesn't function as documented for cgi_directories

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

May 6, 2012, 12:46 AM

Post #1 of 6 (154 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories

Pierre Quentel <pierre.quentel [at] gmail> added the comment:

Hi Glenn, good to hear from you ;-)

I think the fix can be simplified replacing

dir_sep = collapsed_path.find('/', 1)

by

dir_sep = collapsed_path.rfind('/', 1)

----------
nosy: +quentel

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 6, 2012, 2:57 PM

Post #2 of 6 (146 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories [In reply to]

Glenn Linderman <v+python [at] g> added the comment:

Hi Pierre, Nice to see your name pop up again.

Your suggestion is certainly simpler... but unfortunately, too much simpler. One reason, is that in configuring a path to contain CGI files, the CGI files are allowed to be there, or anywhere deeper in the tree. So configuring "/http/bin" should allow the CGI file to be any of:

/http/bin/some.cgi
/http/bin/application1/other.cgi
/http/bin/app2/subapp/third.cgi

and many more.

The second reason, is that once /http/bin is determined to be the path prefix, then the search down the tree is done for the cgi file. Now let's say URL looks like:

http://server.com/http/bin/app2/subapp/third.cgi/more/path/info/params

It is appropriate to find third.cgi and execute it as a CGI file, and pass it as PATHINFO /more/path/info/params ! Yet, using your suggested over-simplification, "params" would be considered the CGI file (if it even exists), and /http/bin/app2/subapp/third.cgi/more/path/info certainly wouldn't exactly match /http/bin... so neither params nor third.cgi would get a chance to be executed.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 6, 2012, 11:14 PM

Post #3 of 6 (148 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories [In reply to]

Pierre Quentel <pierre.quentel [at] gmail> added the comment:

Thanks for the explanation

I still think that the patch can be simplified, not using path lengths and the "found" flag

collapsed_path = _url_collapse_path(self.path)
for head in self.cgi_directories:
if head==collapsed_path:
self.cgi_info = (head,'')
return True
elif collapsed_path.startswith(head) \
and collapsed_path[len(head)]=='/':
self.cgi_info = head, collapsed_path[len(head)+1:]
return True
return False

BTW the last "return False" is rather useless since is_cgi() is only used in tests like "if is_cgi()"

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 7, 2012, 2:15 PM

Post #4 of 6 (142 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories [In reply to]

Glenn Linderman <v+python [at] g> added the comment:

Hi Pierre,

You are right, the "found" variable is not needed, I guess the reason I coded it that way, is I had some validation code before the return, during testing, so it was easier not to have it in three places.

Regarding precalculating ln, I don't know how Python is coded internally, so it seems that string compares could be lengthier integer compares, and even in your code the length is calculated sometimes. So it is mostly an order of operations optimization... I didn't attempt to benchmark it with various URL and cgi_directories values, including at least both some with large prefix matches, and some without... I didn't figure it would matter much, but if you think it does, then feel free to benchmark.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 7, 2012, 8:37 PM

Post #5 of 6 (144 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories [In reply to]

Changes by √Čric Araujo <merwok [at] netwok>:


----------
versions: -Python 2.6, Python 3.1

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 7, 2012, 11:22 PM

Post #6 of 6 (150 views)
Permalink
[issue14565] is_cgi doesn't function as documented for cgi_directories [In reply to]

Pierre Quentel <pierre.quentel [at] gmail> added the comment:

Hi Glenn,

My proposal was not about optimization, I just thought that "if x==y" is simpler than "if len(x)==len(y) and x==y". Since we don't expect that there will be many directories in the list, I don't think optimizing is so important. But it doesn't matter to me really, the most important is to have the bug fixed

Can you propose a diff file so that the committers can review it ?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14565>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.