From 239ebd40b9a9b88e6b02c713979932e9f950eeb2 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Mon, 5 Aug 2024 11:56:42 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8CUNIFI=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/plugins/plugin_helper.py | 9 +++++++++ front/plugins/unifi_import/script.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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' # -----------------------------------------------------------------------------