I just checked out the latest Zope 2 CVS.

In lib/python/Products/ZCatalog/CatalogAwareness.py, the method "url":

    def url(self, ftype=urllib.splittype, fhost=urllib.splithost):
        """Return a SCRIPT_NAME-based url for an object."""
        if hasattr(self, 'DestinationURL') and \
            url='%s/%s' % (self.DestinationURL(), self.id)
        else: url=self.absolute_url()
        type, uri=ftype(url)
        host, uri=fhost(uri)
        __traceback_info__=(`uri`, `script_name`)
        if script_name:
            uri=filter(None, string.split(uri, script_name))[0]
*       if uri[0] != '/': uri = '/' + uri
*       uri=uri or '/'
        return urllib.unquote(uri)

I'm suspicious of the two lines marked with a "*".

The line 

  uri=uri or '/'

seems to imply that url can be the empty string, or possibly None.

However, the line before

  if uri[0] != '/': uri = '/' + uri

Will fail with an IndexError if uri is ''.

Perhaps the two lines ought to be replaced with:

  uri=uri and uri[0]!='/' and '/'+uri or uri or '/'

and perhaps a comment

# input       output
# None        '/'
# ''          '/'
# '/'         '/'
# 'foo'       '/foo'
# '/foo'      '/foo'

This is now in the Collector:


Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to