From 8cbf8e8f57bf859c69850d03e0fc7bbf21764d26 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 22 Jun 2023 18:17:41 +0200 Subject: [PATCH] UI - Dont allow empty tag names (#1641) --- changedetectionio/__init__.py | 15 ++++++++------- changedetectionio/store.py | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index a4c6a4c9..fa6e82a5 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -1364,13 +1364,14 @@ def changedetection_app(config=None, datastore_o=None): flash("{} watches set to use default notification settings".format(len(uuids))) elif (op == 'assign-tag'): - op_extradata = request.form.get('op_extradata') - tag_uuid = datastore.add_tag(name=op_extradata) - if op_extradata and tag_uuid: - for uuid in uuids: - uuid = uuid.strip() - if datastore.data['watching'].get(uuid): - datastore.data['watching'][uuid]['tags'].append(tag_uuid) + op_extradata = request.form.get('op_extradata', '').strip() + if op_extradata: + tag_uuid = datastore.add_tag(name=op_extradata) + if op_extradata and tag_uuid: + for uuid in uuids: + uuid = uuid.strip() + if datastore.data['watching'].get(uuid): + datastore.data['watching'][uuid]['tags'].append(tag_uuid) flash("{} watches assigned tag".format(len(uuids))) diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 8711413e..d7d66b4d 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -566,9 +566,12 @@ class ChangeDetectionStore: return ret def add_tag(self, name): - print (">>> Adding new tag -", name) # If name exists, return that n = name.strip().lower() + print (f">>> Adding new tag - '{n}") + if not n: + return False + for uuid, tag in self.__data['settings']['application'].get('tags', {}).items(): if n == tag.get('title', '').lower().strip(): print (f">>> Tag {name} already exists")