Files
pgadmin4/web/pgadmin/utils/html.py
T

29 lines
706 B
Python
Raw Normal View History

##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
2021-01-04 15:34:45 +05:30
# Copyright (C) 2013 - 2021, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
#########################################################################
"""Utilities for HTML"""
from html import escape as html_escape
2020-02-18 12:10:38 +05:30
def safe_str(x):
try:
# For Python3, it can be int, float
if isinstance(x, (int, float)):
x = str(x)
x = x.encode(
'ascii', 'xmlcharrefreplace'
) if hasattr(x, 'encode') else x
x = x.decode('utf-8')
except Exception:
pass
2020-02-18 12:10:38 +05:30
return html_escape(x, False)