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