From ee673b92ce7edea4ae7b7afe0042723294b6641a Mon Sep 17 00:00:00 2001 From: bashrc Date: Wed, 18 Mar 2026 12:00:20 +0000 Subject: [PATCH] More hashtag validation --- categories.py | 7 ++++++- utils.py | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/categories.py b/categories.py index 5d629c0f0..f175e0f41 100644 --- a/categories.py +++ b/categories.py @@ -13,6 +13,7 @@ from timeFunctions import date_utcnow from timeFunctions import date_epoch from utils import data_dir from utils import replace_strings +from utils import get_invalid_characters MAX_TAG_LENGTH = 42 @@ -226,6 +227,10 @@ def _valid_hashtag_category(category: str) -> bool: if not category: return False + for char in get_invalid_characters(): + if char in category: + return False + for char in INVALID_HASHTAG_CHARS: if char in category: return False @@ -233,7 +238,7 @@ def _valid_hashtag_category(category: str) -> bool: # too long or too short if len(category) > 40: return False - elif len(category) == 0: + if len(category) == 0: return False return True diff --git a/utils.py b/utils.py index ecb6bc14e..92a8c7554 100644 --- a/utils.py +++ b/utils.py @@ -1017,6 +1017,12 @@ def evil_nickname(sending_actor_nickname: str) -> bool: return False +def get_invalid_characters() -> []: + """Returns the list of invalid characters + """ + return INVALID_CHARACTERS + + def contains_invalid_chars(json_str: str) -> bool: """Does the given json string contain invalid characters? """