From 59293c7dd5e272b7b1ff5496aea26a2fb8457b93 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 20 May 2022 11:17:53 +0100 Subject: [PATCH] Hashtags cannot be numbers --- tests.py | 2 ++ utils.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests.py b/tests.py index 1dad076c2..bfb827a62 100644 --- a/tests.py +++ b/tests.py @@ -5573,6 +5573,7 @@ def _test_valid_hash_tag(): assert valid_hash_tag('한국어') assert valid_hash_tag('테스트') assert valid_hash_tag('테_스트') + assert valid_hash_tag('c99') assert not valid_hash_tag('this-is-invalid') assert not valid_hash_tag('ThisIsNotValid!') assert not valid_hash_tag('#ThisIsAlsoNotValid') @@ -5581,6 +5582,7 @@ def _test_valid_hash_tag(): assert not valid_hash_tag('ThisIsAlsoNotValid"') assert not valid_hash_tag('This Is Also Not Valid"') assert not valid_hash_tag('This=IsAlsoNotValid"') + assert not valid_hash_tag('12345') def _test_markdown_to_html(): diff --git a/utils.py b/utils.py index dc9abb7ad..6fc1adf7d 100644 --- a/utils.py +++ b/utils.py @@ -3535,6 +3535,9 @@ def valid_hash_tag(hashtag: str) -> bool: # long hashtags are not valid if len(hashtag) >= 32: return False + # numbers are not permitted to be hashtags + if hashtag.isdigit(): + return False if set(hashtag).issubset(VALID_HASHTAG_CHARS): return True if _is_valid_language(hashtag):