Check for invalid ciphertext later

merge-requests/30/head
Bob Mottram 2021-11-22 11:59:41 +00:00
parent d98e68be5b
commit 442c4f4daa
2 changed files with 4 additions and 6 deletions

View File

@ -242,7 +242,6 @@ from like import updateLikesCollection
from reaction import updateReactionCollection from reaction import updateReactionCollection
from utils import undoReactionCollectionEntry from utils import undoReactionCollectionEntry
from utils import getNewPostEndpoints from utils import getNewPostEndpoints
from utils import malformedCiphertext
from utils import hasActor from utils import hasActor
from utils import setReplyIntervalHours from utils import setReplyIntervalHours
from utils import canReplyTo from utils import canReplyTo
@ -1503,11 +1502,6 @@ class PubServer(BaseHTTPRequestHandler):
# save the json for later queue processing # save the json for later queue processing
messageBytesDecoded = messageBytes.decode('utf-8') messageBytesDecoded = messageBytes.decode('utf-8')
if malformedCiphertext(messageBytesDecoded):
print('WARN: post contains malformed ciphertext ' +
str(originalMessageJson))
return 4
if containsInvalidLocalLinks(messageBytesDecoded): if containsInvalidLocalLinks(messageBytesDecoded):
print('WARN: post contains invalid local links ' + print('WARN: post contains invalid local links ' +
str(originalMessageJson)) str(originalMessageJson))

View File

@ -17,6 +17,7 @@ from languages import understoodPostLanguage
from like import updateLikesCollection from like import updateLikesCollection
from reaction import updateReactionCollection from reaction import updateReactionCollection
from reaction import validEmojiContent from reaction import validEmojiContent
from utils import malformedCiphertext
from utils import removeHtml from utils import removeHtml
from utils import fileLastModified from utils import fileLastModified
from utils import hasObjectString from utils import hasObjectString
@ -2258,6 +2259,9 @@ def _validPostContent(baseDir: str, nickname: str, domain: str,
print('REJECT: reply to post which does not ' + print('REJECT: reply to post which does not ' +
'allow comments: ' + originalPostId) 'allow comments: ' + originalPostId)
return False return False
if malformedCiphertext(messageJson['object']['content']):
print('REJECT: malformed ciphertext in content')
return False
if debug: if debug:
print('ACCEPT: post content is valid') print('ACCEPT: post content is valid')
return True return True