forked from indymedia/epicyon
Check that number of tags is not too large
parent
1480fed196
commit
0f2c863e4e
9
inbox.py
9
inbox.py
|
@ -1110,6 +1110,7 @@ def validPostContent(messageJson: {},maxMentions: int) -> bool:
|
||||||
"""Is the content of a received post valid?
|
"""Is the content of a received post valid?
|
||||||
Check for bad html
|
Check for bad html
|
||||||
Check for hellthreads
|
Check for hellthreads
|
||||||
|
Check number of tags is reasonable
|
||||||
"""
|
"""
|
||||||
if not messageJson.get('object'):
|
if not messageJson.get('object'):
|
||||||
return True
|
return True
|
||||||
|
@ -1117,6 +1118,7 @@ def validPostContent(messageJson: {},maxMentions: int) -> bool:
|
||||||
return True
|
return True
|
||||||
if not messageJson['object'].get('content'):
|
if not messageJson['object'].get('content'):
|
||||||
return True
|
return True
|
||||||
|
# check for bad html
|
||||||
invalidStrings=['<script>','<style>','</html>','</body>','<br>','<hr>']
|
invalidStrings=['<script>','<style>','</html>','</body>','<br>','<hr>']
|
||||||
for badStr in invalidStrings:
|
for badStr in invalidStrings:
|
||||||
if badStr in messageJson['object']['content']:
|
if badStr in messageJson['object']['content']:
|
||||||
|
@ -1124,9 +1126,16 @@ def validPostContent(messageJson: {},maxMentions: int) -> bool:
|
||||||
print('REJECT: '+messageJson['object']['id'])
|
print('REJECT: '+messageJson['object']['id'])
|
||||||
print('REJECT: bad string in post - '+messageJson['object']['content'])
|
print('REJECT: bad string in post - '+messageJson['object']['content'])
|
||||||
return False
|
return False
|
||||||
|
# check (rough) number of mentions
|
||||||
if estimateNumberOfMentions(messageJson['object']['content'])>maxMentions:
|
if estimateNumberOfMentions(messageJson['object']['content'])>maxMentions:
|
||||||
print('REJECT: Too many mentions in post - '+messageJson['object']['content'])
|
print('REJECT: Too many mentions in post - '+messageJson['object']['content'])
|
||||||
return False
|
return False
|
||||||
|
# check number of tags
|
||||||
|
if messageJson['object'].get('tag'):
|
||||||
|
if isinstance(messageJson['object']['tag'], list):
|
||||||
|
if len(messageJson['object']['tag'])>maxMentions*2:
|
||||||
|
print('REJECT: Too many tags in post - '+messageJson['object']['tag'])
|
||||||
|
return False
|
||||||
print('ACCEPT: post content is valid')
|
print('ACCEPT: post content is valid')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue