Skip to content

Commit

Permalink
- Only decode input in html_quote when needed under Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 29, 2019
1 parent 8e2c251 commit 31db30e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,9 @@ Changelog
3.0b9 (unreleased)
------------------

- Only decode input in ``html_quote`` when needed under Python 3
(`Products.PythonScripts#28 <https://github.com/zopefoundation/Products.PythonScripts/issues/28`_>)


3.0b8 (2019-04-26)
------------------
Expand Down
7 changes: 3 additions & 4 deletions src/DocumentTemplate/html_quote.py
Expand Up @@ -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)

0 comments on commit 31db30e

Please sign in to comment.