Check message length early

merge-requests/6/head
Bob Mottram 2019-11-16 00:01:00 +00:00
parent 213d4bdf6e
commit b583869938
1 changed files with 10 additions and 0 deletions

View File

@ -4615,6 +4615,16 @@ class PubServer(BaseHTTPRequestHandler):
print('DEBUG: Reading message')
messageBytes=self.rfile.read(length)
if self.path == '/sharedInbox' or self.path == '/inbox':
lenMessage=len(messageBytes)
if lenMessage>10240:
print('WARN: post to shared inbox is too long '+str(lenMessage)+' bytes')
self._400()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,125)
return
# convert the raw bytes to json
messageJson=json.loads(messageBytes)
# https://www.w3.org/TR/activitypub/#object-without-create