Minimal validation on post summary

main
Bob Mottram 2024-04-21 10:18:30 +01:00
parent b1884b0691
commit a42c884256
2 changed files with 13 additions and 5 deletions

View File

@ -538,8 +538,14 @@ def get_summary_from_post(post_json_object: {}, system_language: str,
"""Returns the summary from the post in the given language
including searching for a matching entry within summaryMap
"""
return get_content_from_post(post_json_object, system_language,
languages_understood, "summary")
summary_str = \
get_content_from_post(post_json_object, system_language,
languages_understood, "summary")
if summary_str:
summary_str = summary_str.strip()
if len(summary_str) < 2:
summary_str = ''
return summary_str
def get_base_content_from_post(post_json_object: {},

View File

@ -2713,9 +2713,10 @@ def individual_post_as_html(signing_priv_key_pem: str,
post_is_sensitive = False
if post_json_object['object'].get('sensitive'):
# sensitive posts should have a summary
if post_json_object['object'].get('summary'):
post_is_sensitive = post_json_object['object']['sensitive']
if isinstance(post_json_object['object']['sensitive'], bool):
# sensitive posts should have a summary
if post_json_object['object'].get('summary'):
post_is_sensitive = post_json_object['object']['sensitive']
if not post_json_object['object'].get('summary'):
post_json_object['object']['summary'] = ''
@ -2885,6 +2886,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
post_id = 'post' + str(create_password(8))
content_str = ''
if summary_str:
# set the content warning
cw_str = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,