diff --git a/front/plugins/plugin_helper.py b/front/plugins/plugin_helper.py index 007bfc98..d1a6ae11 100755 --- a/front/plugins/plugin_helper.py +++ b/front/plugins/plugin_helper.py @@ -49,6 +49,15 @@ def handleEmpty(input): input = re.sub(r'[^\x00-\x7F]+', ' ', input) input = input.replace('\n', '') # Removing new lines return input + +# ------------------------------------------------------------------- +# Sanitizes string +def rmBadChars(input): + + input = handleEmpty(input) + input = input.replace("'", '_') # Removing ' (single quotes) + + return input # ------------------------------------------------------------------- # Check if a valid MAC address diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index 930aa8c3..06792fde 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -19,7 +19,7 @@ from pyunifi.controller import Controller INSTALL_PATH="/app" sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) -from plugin_helper import Plugin_Object, Plugin_Objects +from plugin_helper import Plugin_Object, Plugin_Objects, rmBadChars from logger import mylog from helper import timeNowTZ, get_setting_value import conf @@ -200,7 +200,7 @@ def get_unifi_val(obj, key, default='null'): def get_name(*names: str) -> str: for name in names: if name and name != 'null': - return name + return rmBadChars(name) return 'null' # -----------------------------------------------------------------------------