Add ftp as a supported link type

merge-requests/8/head
Bob Mottram 2021-01-02 10:37:19 +00:00
parent db7043dfd2
commit 2bbdbe9774
2 changed files with 31 additions and 2 deletions

View File

@ -2978,9 +2978,36 @@ def testFunctions():
'-Gsep=+120 -Tx11 epicyon.dot') '-Gsep=+120 -Tx11 epicyon.dot')
def testLinksWithinPost() -> None:
baseDir = os.getcwd()
nickname = 'test27636'
domain = 'rando.site'
port = 443
httpPrefix = 'https'
content = 'This is a test post with links.\n\n' + \
'ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/v4/\n\nhttps://freedombone.net'
postJsonObject = \
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
content,
False, False, False, True,
None, None, False, None)
assert postJsonObject['object']['content'] == \
'<p>This is a test post with links.<br><br>' + \
'<a href="ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/v4/" ' + \
'rel="nofollow noopener noreferrer" target="_blank">' + \
'<span class="invisible">ftp://</span>' + \
'<span class="ellipsis">' + \
'ftp.ncdc.noaa.gov/pub/data/ghcn/v4/</span>' + \
'</a><br><br><a href="https://freedombone.net" ' + \
'rel="nofollow noopener noreferrer" target="_blank">' + \
'<span class="invisible">https://</span>' + \
'<span class="ellipsis">freedombone.net</span></a></p>'
def runAllTests(): def runAllTests():
print('Running tests...') print('Running tests...')
testFunctions() testFunctions()
testLinksWithinPost()
testReplyToPublicPost() testReplyToPublicPost()
testGetMentionedPeople() testGetMentionedPeople()
testGuessHashtagCategory() testGuessHashtagCategory()

View File

@ -328,14 +328,16 @@ def removeIdEnding(idStr: str) -> str:
def getProtocolPrefixes() -> []: def getProtocolPrefixes() -> []:
"""Returns a list of valid prefixes """Returns a list of valid prefixes
""" """
return ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://', return ('https://', 'http://', 'ftp://',
'dat://', 'i2p://', 'gnunet://',
'hyper://', 'gemini://', 'gopher://') 'hyper://', 'gemini://', 'gopher://')
def getLinkPrefixes() -> []: def getLinkPrefixes() -> []:
"""Returns a list of valid web link prefixes """Returns a list of valid web link prefixes
""" """
return ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://', return ('https://', 'http://', 'ftp://',
'dat://', 'i2p://', 'gnunet://',
'hyper://', 'gemini://', 'gopher://', 'briar:') 'hyper://', 'gemini://', 'gopher://', 'briar:')