plone.app.multilingual/master: Safely convert field value to unicode

Peter Holzer <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.app.multilingual
Branch: refs/heads/master
Date: 2017-07-18T12:54:58+02:00
Author: Peter Holzer (agitator) <peter.holzer-2KzcThb1VtpWk0Htik3J/[email protected]>
Commit: https://github.com/plone/plone.app.multilingual/commit/68323325ad7b4184b99568e5a0f39c3a47e05c77

Safely convert field value to unicode

Files changed:
M CHANGES.rst
M src/plone/app/multilingual/dx/cloner.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 67c42f3f..37e9f8e5 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -11,7 +11,7 @@ Breaking changes:
 New features:
 
 - Rebuilt po files
-  [erral]  
+  [erral]
 
 - Rename ``media`` folder to a more generic name ``assets`` by default and
   add i18nize it to be localization aware
@@ -19,6 +19,10 @@ New features:
 
 Bug fixes:
 
+- Safely convert field value to unicode
+  [agitator, GerardRodes]
+
+
 - Add missing i18n:translate tags
   [erral]
 
diff --git a/src/plone/app/multilingual/dx/cloner.py b/src/plone/app/multilingual/dx/cloner.py
index aab13980..4c446c36 100644
--- a/src/plone/app/multilingual/dx/cloner.py
+++ b/src/plone/app/multilingual/dx/cloner.py
@@ -1,16 +1,18 @@
 # -*- coding: utf-8 -*-
 from plone.app.multilingual.dx.interfaces import ILanguageIndependentField
-from Products.CMFPlone.interfaces import ILanguage
 from plone.app.multilingual.interfaces import ILanguageIndependentFieldsManager
 from plone.app.multilingual.interfaces import ITranslationCloner
 from plone.app.multilingual.interfaces import ITranslationManager
 from plone.dexterity.utils import iterSchemata
+from Products.CMFPlone.interfaces import ILanguage
+from Products.CMFPlone.utils import safe_unicode
 from z3c.relationfield import RelationValue
 from z3c.relationfield.interfaces import IRelationList
 from z3c.relationfield.interfaces import IRelationValue
 from zope.component import getUtility
 from zope.component import queryAdapter
 from zope.interface import implementer
+
 import pkg_resources
 try:
     # pkg_resources.get_distribution('zope.initd')
@@ -74,7 +76,8 @@ def relation_copier(rel, lang=target_language, fun=self.copy_relation):
                         value = map(relation_copier, value or [])
 
                     doomed = True
-                    setattr(schema(translation), field_name, value)
+                    setattr(schema(translation),
+                            field_name, safe_unicode(value))
 
         # If at least one field has been copied over to the translation
         # we need to inform subscriber to trigger an ObjectModifiedEvent



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.