Products.CMFCore.DynamicType.icon buggy reliance on length of portal_url
Bug #1202879 reported by
Darryl Dixon
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope CMF buildout |
New
|
Undecided
|
Unassigned |
Bug Description
This commit:
http://
Introduced an implicit assumption about the length of portal_url which is not necessarily always true - it assumes both that it is non-zero length and that it does not include "/" at the end of itself. This line is the problematic one:
icon = icon[len(
In order to make this line safe, the code just needs to by slightly more defensive; it needs:
a) to test for non-zero portal_url, and
b) to test that portal_url does *not* end with "/"
Otherwise, this method may return values like:
"ocument_icon.png"
To post a comment you must log in.
An example of a working version of the affected function would be:
def icon(self, relative_ to_portal= 0): (portal_ url): portal_ url):] ('/'):
icon = icon[1:] 'BASEPATH1' ]
icon = '%s/%s' % (utool(relative=1), icon)
"""
Using this method allows the content class
creator to grab icons on the fly instead of using a fixed
attribute on the class.
"""
utool = getToolByName(self, 'portal_url')
portal_url = utool()
icon = self.getIconURL()
if portal_url:
if icon.startswith
icon = icon[len(
while icon.startswith
if not relative_to_portal:
# Relative to REQUEST[
return icon