[Python 3 compatibility] Introduced a separate HTML safe string function

in 'utils' module, earlier the function -'escape(...)' was converting
the strings to bytes, and that's reason, it was not working on Python 3.
This commit is contained in:
Ashesh Vashi
2016-05-16 11:58:36 +05:30
parent 3bbfd8a19f
commit 8bd17cb433
4 changed files with 44 additions and 37 deletions

18
web/pgadmin/utils/html.py Normal file
View File

@@ -0,0 +1,18 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
#########################################################################
"""Utilities for HTML"""
import cgi
def safe_str(x):
return cgi.escape(x).encode(
'ascii', 'xmlcharrefreplace'
).decode()