A critique of cgi.escape

Max M maxm at mxm.dk
Mon Sep 25 10:59:26 EDT 2006


Jon Ribbens skrev:
> In article <ef8oqr$9pt$1 at news.albasani.net>, Georg Brandl wrote:
>>> I'm sorry, that's not good enough. How, precisely, would it break
>>> "existing code"? Can you come up with an example, or even an
>>> explanation of how it *could* break existing code?
>> Is that so hard to see? If cgi.escape replaced "'" with an entity reference,
>> code that expects it not to do so would break.
> 
> Sorry, that's still not good enough. Why would any code expect such a
> thing?


Oh ... because you cannot see a use case for that *documented* 
behaviour, it must certainly be wrong?


This funktion which is correct by current documentation will be broken 
by you change.

def hasSomeWord(someword):
     import urllib
     f = urllib.open('http://www.example.com/cgi_escaped_content')
     content = f.read()
     f.close()
     return '"%s"' % someword in content:

You might think that it is stupid code that should be changed to take 
escaped quotes into account. But that is really not your bussines to 
decide if the other behaviour is documented and correct.

I find it amazing that you cannot understand this. I will stop replying 
in this thread now.

Max M



More information about the Python-list mailing list