Skip to content

Commit

Permalink
Revert "When calling the html serializer pass an encoding"
Browse files Browse the repository at this point in the history
This reverts commit fc246c0.
  • Loading branch information
ale-rt committed Apr 30, 2024
1 parent fc246c0 commit 32c2994
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
1 change: 0 additions & 1 deletion news/238.bugfix

This file was deleted.

27 changes: 1 addition & 26 deletions src/plone/app/theming/tests/test_transform.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from App.config import getConfiguration
from diazo.compiler import compile_theme
from html import unescape
from lxml import etree
from os import environ
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.theming.interfaces import IThemeSettings
from plone.app.theming.testing import THEMING_FUNCTIONAL_TESTING
from plone.app.theming.testing import THEMING_INTEGRATION_TESTING
from plone.app.theming.transform import ThemeTransform
from plone.app.theming.utils import applyTheme
from plone.app.theming.utils import getTheme
Expand All @@ -27,30 +25,7 @@
import unittest


class IntegrationTestCase(unittest.TestCase):

layer = THEMING_INTEGRATION_TESTING

def test_transform_parseTree_with_unicode(self):
request = self.layer["request"]
request.response.setHeader("Content-Type", "text/html; charset=utf-8")
transform = ThemeTransform(None, request)
snippet = "\n".join(
(
"<!DOCTYPE html>",
"<html>",
"<body>",
"<div>à</div>",
"</body>",
"</html>",
)
)
parsed = transform.parseTree([snippet.encode()])
serialized = unescape(parsed.serialize().decode())
self.assertEqual(snippet, serialized)


class FunctionalTestCase(unittest.TestCase):
class TestCase(unittest.TestCase):
layer = THEMING_FUNCTIONAL_TESTING

def setUp(self):
Expand Down
5 changes: 1 addition & 4 deletions src/plone/app/theming/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface
from ZPublisher.HTTPRequest import default_encoding

import logging

Expand Down Expand Up @@ -121,9 +120,7 @@ def parseTree(self, result):
return None

try:
return getHTMLSerializer(
result, pretty_print=False, encoding=default_encoding
)
return getHTMLSerializer(result, pretty_print=False)
except (AttributeError, TypeError, etree.ParseError):
return None

Expand Down

0 comments on commit 32c2994

Please sign in to comment.