Skip to content

Commit

Permalink
Do not assume the data to be transformed is an encoded string, it may…
Browse files Browse the repository at this point in the history
… already be unicode.
  • Loading branch information
alecpm committed Sep 7, 2015
1 parent feb2c58 commit 3f22979
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion collective/embedly/transform.py
Expand Up @@ -3,6 +3,7 @@
import re
import logging
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from Products.PortalTransforms.interfaces import ITransform
from zope.interface import implements
from zope.component import getUtility, queryUtility
Expand Down Expand Up @@ -241,7 +242,7 @@ def convert(self, data, idata, filename=None, **kwargs):
if context:
putils = getToolByName(context, 'plone_utils')
encoding = putils.getSiteEncoding()
data = data.decode(encoding)
data = safe_unicode(data, encoding)
text = parse(data, context.absolute_url())
text = text.encode(encoding)
else:
Expand Down
3 changes: 3 additions & 0 deletions docs/HISTORY.rst
Expand Up @@ -4,6 +4,9 @@ Changelog
dev
---

- Don't attempt to decode unicode strings in transform.
[alecm]

- Add embedly API key to requests in preview mode (this fixes #19)
[fRiSi]

Expand Down

0 comments on commit 3f22979

Please sign in to comment.