plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 186 forks source link

Configuration registry edit form fails for images in Bytes field (logo) #3215

Closed mauritsvanrees closed 1 year ago

mauritsvanrees commented 3 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

This is split off from my comment on site logo migration. But for clarity I make this an issue with a fresh Plone Site.

What I did:

What I expect to happen:

Logo is shown.

What actually happened:

Traceback (most recent call last):
  File "/Users/maurits/shared-eggs/cp38/Chameleon-3.8.1-py3.8.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/Users/maurits/community/plone-coredev/py3/var/cache/7a4dbf62a3f320b68f6c7a0d24b5f9a6.py", line 118, in render
    __cache_4573067728 = _static_4567212624('provider', 'plone.portalheader', econtext=econtext)(_static_4567212432(econtext, __zt_tmp))
  File "/Users/maurits/shared-eggs/cp38/zope.contentprovider-4.2.1-py3.8.egg/zope/contentprovider/tales.py", line 76, in __call__
    provider.update()
  File "/Users/maurits/shared-eggs/cp38/zope.viewlet-4.2.1-py3.8.egg/zope/viewlet/manager.py", line 155, in update
    self._updateViewlets()
  File "/Users/maurits/shared-eggs/cp38/zope.viewlet-4.2.1-py3.8.egg/zope/viewlet/manager.py", line 161, in _updateViewlets
    viewlet.update()
  File "/Users/maurits/shared-eggs/cp38/plone.app.layout-3.4.6-py3.8.egg/plone/app/layout/viewlets/common.py", line 227, in update
    self.img_src = getSiteLogo()
  File "/Users/maurits/community/plone-coredev/py3/src/Products.CMFPlone/Products/CMFPlone/utils.py", line 776, in getSiteLogo
    filename, data = b64decode_file(settings.site_logo)
  File "/Users/maurits/shared-eggs/cp38/plone.formwidget.namedfile-2.1.0-py3.8.egg/plone/formwidget/namedfile/converter.py", line 77, in b64decode_file
    filename, data = value.split(b';')
ValueError: too many values to unpack (expected 2)

I have also seen "not enough values to unpack". I am not sure if the difference is for using Python 2 instead, or because I uploaded an SVG then.

Searching for the site logo again in the config registry I see a value starting with PNG IHDR ' e@4 sRGB... or for SVG: filenameb64:....

What version of Plone/ Addons I am using:

Coredev 5.2, Python 2.7 or 3.8.

Alternative steps to take:

The traceback suggests this should be fixed in plone.formwidget.namedfile, but maybe the error is elsewhere in the stack.

jensens commented 1 year ago

is this still an issue in Plone 6?

mauritsvanrees commented 1 year ago

No issue anymore. Checked on Plone 6, and on 5.2 in both Py 2 and 3.