Check if image alt text is the same as content

main
bashrc 2026-08-18 10:21:11 +01:00
parent c855fbb034
commit 8e1c7c2f80
1 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,7 @@ from pprint import pprint
from src.flags import has_group_type from src.flags import has_group_type
from src.flags import url_permitted from src.flags import url_permitted
from src.status import get_status_number from src.status import get_status_number
from src.utils import remove_html
from src.utils import remove_post_from_cache from src.utils import remove_post_from_cache
from src.utils import get_cached_post_filename from src.utils import get_cached_post_filename
from src.utils import load_json from src.utils import load_json
@ -772,6 +773,7 @@ def disallow_announce(content: str, attachment: [], capabilities: {}) -> bool:
return True return True
# check for attached images without descriptions # check for attached images without descriptions
# or where the description is the same as the content
if isinstance(attachment, list): if isinstance(attachment, list):
for item in attachment: for item in attachment:
if not isinstance(item, dict): if not isinstance(item, dict):
@ -791,4 +793,10 @@ def disallow_announce(content: str, attachment: [], capabilities: {}) -> bool:
if len(image_description) < 5: if len(image_description) < 5:
# not enough description # not enough description
return True return True
# compare content with description, removing any formatting
content2 = content.strip().lower()
description2 = image_description.strip().lower()
if remove_html(content2) == remove_html(description2):
# content is the same as description
return True
return False return False