mirror of https://gitlab.com/bashrc2/epicyon
Latin-script special characters are valid
parent
00af89ff3e
commit
7de4e24f2e
|
@ -380,9 +380,14 @@ def validHashTag(hashtag: str) -> bool:
|
|||
# TODO: this may need to be an international character set
|
||||
validChars = set('0123456789' +
|
||||
'abcdefghijklmnopqrstuvwxyz' +
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
|
||||
'¡¿ÄäÀàÁáÂâÃãÅåǍǎĄąĂăÆæĀā' +
|
||||
'ÇçĆćĈĉČčĎđĐďðÈèÉéÊêËëĚěĘęĖėĒē' +
|
||||
'ĜĝĢģĞğĤĥÌìÍíÎîÏïıĪīĮįĴĵĶķ' +
|
||||
'ĹĺĻļŁłĽľĿŀÑñŃńŇňŅņÖöÒòÓóÔôÕõŐőØøŒœ' +
|
||||
'ŔŕŘřẞߌśŜŝŞşŠšȘșŤťŢţÞþȚțÜüÙùÚúÛûŰűŨũŲųŮůŪū' +
|
||||
'ŴŵÝýŸÿŶŷŹźŽžŻż')
|
||||
if set(hashtag).issubset(validChars):
|
||||
if '&' not in hashtag and '#' not in hashtag:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
14
tests.py
14
tests.py
|
@ -76,6 +76,7 @@ from inbox import jsonPostAllowsComments
|
|||
from inbox import validInbox
|
||||
from inbox import validInboxFilenames
|
||||
from categories import guessHashtagCategory
|
||||
from content import validHashTag
|
||||
from content import htmlReplaceEmailQuote
|
||||
from content import htmlReplaceQuoteMarks
|
||||
from content import dangerousCSS
|
||||
|
@ -3088,9 +3089,22 @@ def testPrepareHtmlPostNickname():
|
|||
assert result == expectedHtml
|
||||
|
||||
|
||||
def testValidHashTag():
|
||||
print('testValidHashTag')
|
||||
assert validHashTag('ThisIsValid')
|
||||
assert validHashTag('ThisIsValid12345')
|
||||
assert validHashTag('ThisIsVälid')
|
||||
assert not validHashTag('ThisIsNotValid!')
|
||||
assert not validHashTag('#ThisIsAlsoNotValid')
|
||||
assert not validHashTag('ThisIsAlso&NotValid')
|
||||
assert not validHashTag('ThisIsAlsoNotValid"')
|
||||
assert not validHashTag('This=IsAlsoNotValid"')
|
||||
|
||||
|
||||
def runAllTests():
|
||||
print('Running tests...')
|
||||
testFunctions()
|
||||
testValidHashTag()
|
||||
testPrepareHtmlPostNickname()
|
||||
testDomainHandling()
|
||||
testMastoApi()
|
||||
|
|
Loading…
Reference in New Issue