From 9a7c90b194db598b3c0b13c9a56e08795ecdd555 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 27 Dec 2022 07:49:50 +0000 Subject: [PATCH] only if powershell --- api/tacticalrmm/tacticalrmm/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/tacticalrmm/utils.py b/api/tacticalrmm/tacticalrmm/utils.py index 5c98df7c..ab1a6d30 100644 --- a/api/tacticalrmm/tacticalrmm/utils.py +++ b/api/tacticalrmm/tacticalrmm/utils.py @@ -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