From 4aa56256e88f0444e1563b7e1259a17bf8ca92f6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 30 Sep 2019 10:43:46 +0100 Subject: [PATCH] Validate post content --- inbox.py | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/inbox.py b/inbox.py index e3bd55bc..22670a5a 100644 --- a/inbox.py +++ b/inbox.py @@ -1095,7 +1095,26 @@ def populateReplies(baseDir :str,httpPrefix :str,domain :str, \ repliesFile.write(messageId+'\n') repliesFile.close() return True - + +def validPostContent(messageJson: {}) -> bool: + """Is the content of a received post valid? + """ + if not messageJson.get('object'): + return True + if not isinstance(messageJson['object'], dict): + return True + if not messageJson['object'].get('content'): + return True + invalidStrings=['