diff --git a/CHANGES.rst b/CHANGES.rst index a88a20f..7519220 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changelog 3.0b9 (unreleased) ------------------ +- Only decode input in ``html_quote`` when needed under Python 3 + (`Products.PythonScripts#28 ) + 3.0b8 (2019-04-26) ------------------ diff --git a/src/DocumentTemplate/html_quote.py b/src/DocumentTemplate/html_quote.py index 47590c6..69a1f7f 100644 --- a/src/DocumentTemplate/html_quote.py +++ b/src/DocumentTemplate/html_quote.py @@ -10,9 +10,8 @@ def html_quote(v, name='(Unknown name)', md={}, encoding=None): - if encoding is None: - encoding = 'Latin-1' # the old default v = ustr(v) - if isinstance(v, six.binary_type): - v = v.decode(encoding) + if six.PY3 and isinstance(v, six.binary_type): + # decode using the old default if no encoding is passed + v = v.decode(encoding or 'Latin-1') return escape(v, 1)