UnicodeDecodeError saving Page Template

Bug #143867 reported by Yury Don
4
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Low
Andreas Jung

Bug Description

We user koi8-r enconding in zope. management_page_charset property set to "koi8-r".
After instaling zope 2.10.2 we added environment variable ZPT_PREFERRED_ENCODING="koi8-r" and overrides.zcml in /Products/PageTemplates with ReplacingUnicodeEncodingConflictResolver.
Rendering of page templates works fine, but when i try to change page template with cyrillic charactres in text or title, I getting an error:
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-3: invalid data
The error is in lines 193-194 of /Products/PageTemplates/ZopePageTemplate.py
        # The ZMI edit view uses utf-8! So we can safely assume
        # that 'title' and 'text' are utf-8 encoded strings - hopefully

        self.pt_setTitle(title, 'utf-8')
        text = unicode(text, 'utf-8')
Indeed The ZMI edit view uses utf-8 only if management_page_charset not available.
Replacing string
       self.pt_setTitle(title, 'utf-8')
       text = unicode(text, 'utf-8')
to
        text, encoding = convertToUnicode(text,
                                         content_type,
                                         preferred_encodings)
       self.pt_setTitle(title, encoding)
solved the problem.
Diff file fo ZopePageTemplate.py attached.

Revision history for this message
Yury Don (gercon) wrote :
Revision history for this message
Andreas Jung (ajung) wrote :

Could you please work on a unittest?

Andreas Jung (ajung)
Changed in zope2:
assignee: nobody → ajung
Revision history for this message
Andreas Jung (ajung) wrote :

I tried to reproduce that once again (using latin as encoding, sorry, I have no russian setup)...works for me. If you want this fixed, we need a unittest. Otherwise the report will remain open and untouched.

Tres Seaver (tseaver)
Changed in zope2:
importance: Medium → Low
status: New → Triaged
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope2 project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope2.

Changed in zope2:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.