mirror of https://gitlab.com/bashrc2/epicyon
Check for invalid local links in incoming posts
parent
2d232b321b
commit
f7dddc7408
22
content.py
22
content.py
|
@ -1184,3 +1184,25 @@ def wordsSimilarity(content1: str, content2: str, minWords: int) -> int:
|
|||
else:
|
||||
diff += abs(histogram2[combinedWords] - histogram1[combinedWords])
|
||||
return 100 - int(diff * 100 / len(histogram1.items()))
|
||||
|
||||
|
||||
def containsInvalidLocalLinks(content: str) -> bool:
|
||||
"""Returns true if the given content has invalid links
|
||||
"""
|
||||
invalidStrings = (
|
||||
'mute', 'unmute', 'editeventpost', 'notifypost',
|
||||
'delete', 'options', 'page', 'repeat',
|
||||
'bm', 'tl', 'actor', 'unrepeat',
|
||||
'unannounce', 'like', 'unlike', 'bookmark',
|
||||
'unbookmark', 'likedBy', 'id', 'time',
|
||||
'year', 'month', 'day', 'editnewpost',
|
||||
'graph', 'showshare', 'category', 'showwanted',
|
||||
'rmshare', 'rmwanted', 'repeatprivate',
|
||||
'unrepeatprivate', 'replyto',
|
||||
'replyfollowers', 'replydm', 'editblogpost',
|
||||
'handle', 'blockdomain'
|
||||
)
|
||||
for invStr in invalidStrings:
|
||||
if '/?' + invStr + '=' in content:
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -299,6 +299,7 @@ from utils import hasGroupType
|
|||
from manualapprove import manualDenyFollowRequestThread
|
||||
from manualapprove import manualApproveFollowRequestThread
|
||||
from announce import createAnnounce
|
||||
from content import containsInvalidLocalLinks
|
||||
from content import getPriceFromString
|
||||
from content import replaceEmojiFromTags
|
||||
from content import addHtmlTags
|
||||
|
@ -1489,6 +1490,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
# save the json for later queue processing
|
||||
messageBytesDecoded = messageBytes.decode('utf-8')
|
||||
|
||||
if containsInvalidLocalLinks(messageBytesDecoded):
|
||||
print('WARN: post contains invalid local links ' +
|
||||
str(originalMessageJson))
|
||||
return 4
|
||||
|
||||
self.server.blockedCacheLastUpdated = \
|
||||
updateBlockedCache(self.server.baseDir,
|
||||
self.server.blockedCache,
|
||||
|
|
Loading…
Reference in New Issue