Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let HTML tile fail on non ascii content #66

Merged
merged 1 commit into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
omit =
/home/*/.buildout/eggs/*
/usr/*
bin/test
bin/*
/home/travis/buildout-cache/eggs/*
/home/travis/virtualenv/*
eggs/*
parts/*
lib*
include
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ bin
develop-eggs
parts
build
/include
/lib*
pip-selfcheck.json
14 changes: 5 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ env:
cache:
pip: true
directories:
- $HOME/buildout-cache
- $HOME/eggs
matrix:
fast_finish: true
before_install:
- mkdir -p $HOME/buildout-cache/{eggs,downloads}
- mkdir $HOME/.buildout
- echo "[buildout]" > $HOME/.buildout/default.cfg
- echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg
- echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg
- pip install zc.buildout
- virtualenv .
- bin/pip install --upgrade zc.buildout==2.8.0 setuptools==34.1.1
- cp test-$PLONE_VERSION.cfg buildout.cfg
install:
- buildout -N -t 3 annotate
- buildout -N -t 3
- bin/buildout -N -t 3 annotate
- bin/buildout -N -t 3
script:
- bin/code-analysis
- bin/test
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
2.1.1 (unreleased)
------------------

- Nothing changed yet.
Bug fixes:
- Fix non ASCII HTML tile content
[tomgross]


2.1.0 (2017-02-24)
Expand Down
3 changes: 2 additions & 1 deletion plone/app/standardtiles/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from plone.tiles import Tile
from plone.tiles.directives import ignore_querystring
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from zope import schema


Expand Down Expand Up @@ -37,4 +38,4 @@ def __call__(self):
content = data.getData()
else:
content = u'<p></p>'
return u"<html><body>%s</body></html>" % content
return u"<html><body>%s</body></html>" % safe_unicode(content)
9 changes: 9 additions & 0 deletions plone/app/standardtiles/tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from PIL import Image
from PIL import ImageDraw
from plone.app.standardtiles.embed import NOEMBED_ENDPOINT
from plone.app.standardtiles.html import HTMLTile
from plone.app.standardtiles.testing import PASTANDARDTILES_FUNCTIONAL_TESTING
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
Expand Down Expand Up @@ -333,3 +334,11 @@ def test_rawhtml_tile(self):
root = fromstring(self.browser.contents)
nodes = root.xpath('//body/p')
self.assertEqual(nodes[0].text, 'Hello World!')

def test_rawhtml_tile_utf8(self):
tile = HTMLTile(self.portal, self.layer['request'])
tile.data['content'] = u'<p>Hello Wörld!</p>'.encode('utf-8')
self.assertEqual(
tile(),
u'<html><body><p>Hello Wörld!</p></body></html>'
)