Hashtags cannot be numbers

merge-requests/30/head
Bob Mottram 2022-05-20 11:17:53 +01:00
parent 143b415941
commit 59293c7dd5
2 changed files with 5 additions and 0 deletions

View File

@ -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():

View File

@ -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):