Remove any html from image descriptions

main
Bob Mottram 2023-01-07 13:56:52 +00:00
parent 1bc5f2515e
commit 7657fe5e43
4 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import webbrowser
import urllib.parse import urllib.parse
from pathlib import Path from pathlib import Path
from random import randint from random import randint
from utils import remove_html
from utils import safe_system_string from utils import safe_system_string
from utils import text_in_file from utils import text_in_file
from utils import disallow_announce from utils import disallow_announce
@ -25,7 +26,6 @@ from utils import has_object_dict
from utils import get_full_domain from utils import get_full_domain
from utils import is_dm from utils import is_dm
from utils import load_translations_from_file from utils import load_translations_from_file
from utils import remove_html
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import get_domain_from_actor from utils import get_domain_from_actor
from utils import is_pgp_encrypted from utils import is_pgp_encrypted
@ -682,6 +682,7 @@ def _get_image_description(post_json_object: {}) -> str:
message_str = img['name'] message_str = img['name']
if message_str: if message_str:
message_str = message_str.strip() message_str = message_str.strip()
message_str = remove_html(message_str)
if not message_str.endswith('.'): if not message_str.endswith('.'):
image_description += message_str + '. ' image_description += message_str + '. '
else: else:

View File

@ -72,6 +72,7 @@ from tests import test_update_actor
from tests import run_all_tests from tests import run_all_tests
from auth import store_basic_credentials from auth import store_basic_credentials
from auth import create_password from auth import create_password
from utils import remove_html
from utils import remove_eol from utils import remove_eol
from utils import text_in_file from utils import text_in_file
from utils import remove_domain_port from utils import remove_domain_port
@ -1665,7 +1666,7 @@ def _command_options() -> None:
cc_url = None cc_url = None
send_message = argb.message send_message = argb.message
# client_to_server = argb.client # client_to_server = argb.client
attached_image_description = argb.imageDescription attached_image_description = remove_html(argb.imageDescription)
city = 'London, England' city = 'London, England'
send_threads = [] send_threads = []
post_log = [] post_log = []

View File

@ -473,7 +473,7 @@ def _post_to_speaker_json(base_dir: str, http_prefix: str,
if img.get('name'): if img.get('name'):
if isinstance(img['name'], str): if isinstance(img['name'], str):
image_description += \ image_description += \
img['name'] + '. ' remove_html(img['name']) + '. '
is_direct = is_dm(post_json_object) is_direct = is_dm(post_json_object)
actor = local_actor_url(http_prefix, nickname, domain_full) actor = local_actor_url(http_prefix, nickname, domain_full)

View File

@ -1238,6 +1238,7 @@ def get_post_attachments_as_html(base_dir: str,
image_description = '' image_description = ''
if attach.get('name'): if attach.get('name'):
image_description = attach['name'].replace('"', "'") image_description = attach['name'].replace('"', "'")
image_description = remove_html(image_description)
if _is_image_mime_type(media_type): if _is_image_mime_type(media_type):
image_url = attach['url'] image_url = attach['url']