Skip to content

Commit

Permalink
use safe_nativestring to transform before html.fromstring
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer authored and jensens committed Oct 17, 2018
1 parent 905e285 commit d3080eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Products/PortalTransforms/transforms/safe_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import six

from Products.CMFPlone.interfaces import IFilterSchema
from Products.CMFPlone.utils import safe_encode
from Products.PortalTransforms.interfaces import ITransform
from Products.PortalTransforms.libtransforms.utils import bodyfinder
from lxml import etree
Expand Down Expand Up @@ -2398,10 +2399,8 @@ def convert(self, orig, data, **kwargs):
def scrub_html(self, orig):
# append html tag to create a dummy parent for the tree
html_parser = html.HTMLParser(encoding='utf-8')
if isinstance(orig, six.binary_type):
tag = b'<html'
else:
tag = '<html'
orig = safe_encode(orig)
tag = b'<html'
if tag in orig.lower():
# full html
tree = html.fromstring(orig, parser=html_parser)
Expand Down
1 change: 1 addition & 0 deletions news/38.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix scrub_html when passing unicode [pbauer]

0 comments on commit d3080eb

Please sign in to comment.