GenericSetup: Buggy TAR-Export for Workflows with Non-Ascii-Characters

Bug #716038 reported by Roman Jansen-Winkeln
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zope CMF buildout
Fix Released
Undecided
Unassigned

Bug Description

We stumbled in problems with broken TAR-Exports from GenericSetup exports of DCWorkflows.

The reason: our interactively defined workflows contained non-ascii unicode characters.

For the enclosed example file "definitions.xml", the method "writeDataFile" in class "TarballExportContext" in file "context.py" of Products.GenerictSetup-1.6.1 reports in "info.size = len( text )" a length of 8300 characters. The real length of the file is however 8324 bytes, which is len(str(text)).
The relevant workflow in the attached (fixed) export is

We have developped a simple workaround and replaced the original:

        stream = StringIO( text )
        info = TarInfo( filename )
        info.size = len( text )

with

        text = str(text) ### Patch to convert unicode to bytes [RJW 2011-02-09]
        stream = StringIO( text )
        info = TarInfo( filename )
        info.size = len( text ) # len is wrong for utf-8 encoding

It works fine for our purposes. There may surely be a more elegant solution.

The bug appears in Plone 3.3.x and in Plone 4.0.x . Python operates in "utf-8" mode.

Best Regards
roman

Revision history for this message
Roman Jansen-Winkeln (rjw-satzweiss) wrote :
description: updated
Revision history for this message
rafaelb (rafaelbco) wrote :

I confirm this bug.

Revision history for this message
Tres Seaver (tseaver) wrote :

'str(text)' won't work if 'text' is non-ASCII unicode, unless you have
set 'sys.defaultencoding' (which is frowned upon as a general practice).

I will investigate: valid XML files must be encoded to UTF-8 unless they
specify a different encoding inline, which makes that the right encoding.

Revision history for this message
Tres Seaver (tseaver) wrote :

r123435 explicitly prohibits passing Unicode to the 'writeDataFile'
method of an export context: it is now the responsibility of the
handler generating the XML to encode it before passing it to the
context.

Changed in zope-cmf:
status: New → Fix Released
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.