pgadmin4/web/pgadmin/utils/html.py

24 lines
589 B
Python
Raw Normal View History

##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
2017-01-04 07:33:32 -06:00
# Copyright (C) 2013 - 2017, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
#########################################################################
"""Utilities for HTML"""
import cgi
from pgadmin.utils import IS_PY2
def safe_str(x):
try:
x = x.encode('ascii', 'xmlcharrefreplace') if hasattr(x, 'encode') else x
if not IS_PY2:
x = x.decode('utf-8')
except:
pass
return cgi.escape(x)