mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-12-01 21:09:10 -06:00
ad80217593
refs #5443 Initial patch: Neel Patel
29 lines
706 B
Python
29 lines
706 B
Python
##########################################################################
|
|
#
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
#
|
|
# Copyright (C) 2013 - 2020, The pgAdmin Development Team
|
|
# This software is released under the PostgreSQL Licence
|
|
#
|
|
#########################################################################
|
|
|
|
"""Utilities for HTML"""
|
|
|
|
from html import escape as html_escape
|
|
|
|
|
|
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
|
|
return html_escape(x, False)
|