only if powershell

This commit is contained in:
wh1te909 2022-12-27 07:49:50 +00:00
parent 91f2708a87
commit 9a7c90b194
1 changed files with 6 additions and 2 deletions

View File

@ -339,7 +339,7 @@ def replace_db_values(
# check if attr exists and isn't a function
if hasattr(obj, temp[1]) and not callable(getattr(obj, temp[1])):
temp1 = getattr(obj, temp[1])
if isinstance(temp1, str) and "'" in temp1:
if shell == ScriptShell.POWERSHELL and isinstance(temp1, str) and "'" in temp1:
temp1 = temp1.replace("'", "''")
value = f"'{temp1}'" if quotes else temp1
@ -372,7 +372,11 @@ def replace_db_values(
elif value is not None and field.type == CustomFieldType.CHECKBOX:
value = format_shell_bool(value, shell)
else:
if isinstance(value, str) and "'" in value:
if (
shell == ScriptShell.POWERSHELL
and isinstance(value, str)
and "'" in value
):
value = value.replace("'", "''")
value = f"'{value}'" if quotes else value