mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Ensure object names are properly escaped for external process management. Fixes #2405
This commit is contained in:
committed by
Dave Page
parent
f0e78309cb
commit
1cb2a62fa8
@@ -15,7 +15,19 @@ from pgadmin.utils import IS_PY2
|
||||
|
||||
def safe_str(x):
|
||||
try:
|
||||
x = x.encode('ascii', 'xmlcharrefreplace') if hasattr(x, 'encode') else x
|
||||
# For Python2, it can be int, long, float
|
||||
if IS_PY2:
|
||||
if isinstance(x, (int, long, float)):
|
||||
x = str(x)
|
||||
else:
|
||||
# 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
|
||||
|
||||
if not IS_PY2:
|
||||
x = x.decode('utf-8')
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user