-
-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Using getattr without a default value raises an AttributeError, which means the else block is never executed.
On a classic Plone site this leads to unnecessary log entries when uploading a JPG as site logo via the control panel. In that scenario the logo is stored in the registry as raw bytes and therefore has no name attribute.
Although using a different file type (non-JPG) might avoid the issue temporarily, the underlying code is fundamentally incorrect and should be fixed.
Affected Code
https://github.com/plone/plone.namedfile/blob/8286972b4452234c2342534e6fb6ebf549a3d64c/src/plone/namedfile/utils/init.py#L271
Steps to reproduce
- Use a Classic Plone site (6.1.2 or above).
- Open the control panel.
- Upload a JPG file as site logo.
- Visit the homepage or any other page within the Plone site.
Actual behavior
AttributeError is raised and unnecessary log entries get written.
Expected behavior
The code should handle missing attributes gracefully by supplying a default value to getattr, thus avoiding the exception.