Sandbox any potential evilness

main
Bob Mottram 2023-10-30 10:21:37 +00:00
parent 694a913b08
commit 41b9d41d3a
4 changed files with 26 additions and 20 deletions

View File

@ -367,8 +367,8 @@ def html_open_street_map(url: str,
str(longitude + bounding_box_degrees) + \
'%2C' + \
str(latitude + bounding_box_degrees) + \
'&amp;layer=mapnik" style="border: 1px solid black"></iframe>' + \
'<br/><small><a href="' + osm_url + \
'&amp;layer=mapnik" style="border: 1px solid black" sandbox>' + \
'</iframe><br/><small><a href="' + osm_url + \
'">' + translate['View Larger Map'] + '</a></small>\n'
return html_str

View File

@ -55,8 +55,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
channel + '&parent=' + domain + '" ' + \
'frameborder="0" allowfullscreen="true" ' + \
'scrolling="no" height="' + str(height) + \
'" width="' + str(width) + '"></iframe>' + \
'</span>\n</center>\n'
'" width="' + str(width) + '" sandbox>' + \
'</iframe></span>\n</center>\n'
return content
if '>vimeo.com/' in content:
@ -72,7 +72,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen " + \
"tabindex=\"10\"></iframe>\n" + \
"tabindex=\"10\" sandbox></iframe>\n" + \
"</span>\n</center>\n"
return content
@ -96,8 +96,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
video_site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"</span></center>\n"
"allowfullscreen tabindex=\"10\" sandbox>" + \
"</iframe>\n</span></center>\n"
return content
video_site = 'https://youtu.be/'
@ -119,8 +119,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
video_site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"</span></center>\n"
"allowfullscreen tabindex=\"10\" sandbox>" + \
"</iframe>\n</span></center>\n"
return content
invidious_sites = (
@ -169,7 +169,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
video_site + url + "\" width=\"" + \
str(width) + "\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"allowfullscreen tabindex=\"10\" sandbox></iframe>\n" + \
"</span>\n</center>\n"
return content
@ -193,7 +193,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
video_site + url + "\" width=\"" + \
str(width) + "\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen tabindex=\"10\"></iframe>\n" + \
"allowfullscreen tabindex=\"10\" sandbox></iframe>\n" + \
"</span>\n</center>\n"
return content
@ -273,9 +273,8 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
site + url + "\" width=\"" + str(width) + \
"\" height=\"" + str(height) + \
"\" frameborder=\"0\" allow=\"" + \
"fullscreen\" allowfullscreen tabindex=\"10\">' + \
'</iframe>\n" + \
"</span>\n</center>\n"
"fullscreen\" allowfullscreen tabindex=\"10\" sandbox>" + \
"</iframe>\n</span>\n</center>\n"
return content
return content

View File

@ -394,7 +394,7 @@ def html_podcast_episode(translate: {},
" <iframe loading=\"lazy\" decoding=\"async\" src=\"" + \
url + "\" width=\"400\" height=\"300\" " + \
"frameborder=\"0\" allow=\"fullscreen\" " + \
"allowfullscreen>\n </iframe>\n </span>\n"
"allowfullscreen sandbox>\n </iframe>\n </span>\n"
elif 'video' in podcast_properties['linkMimeType']:
video_mime_type = podcast_properties['linkMimeType']
video_msg = 'Your browser does not support the video element.'

View File

@ -1285,6 +1285,7 @@ def get_post_attachments_as_html(base_dir: str,
# chat links
# https://codeberg.org/fediverse/fep/src/branch/main/fep/1970/fep-1970.md
attached_urls = []
for attach in attachment_dict:
if not attach.get('type') or \
not attach.get('name') or \
@ -1305,6 +1306,9 @@ def get_post_attachments_as_html(base_dir: str,
# get the domain for the chat link
chat_domain_str = ''
attach_url = remove_html(attach['href'])
if attach_url in attached_urls:
continue
attached_urls.append(attach_url)
chat_domain, _ = get_domain_from_actor(attach_url)
if chat_domain:
if local_network_host(chat_domain):
@ -1543,6 +1547,14 @@ def get_post_attachments_as_html(base_dir: str,
attachment_str += '<br>'
if box_name == 'tlmedia':
gallery_str += '<div class="gallery">\n'
if post_json_object['object'].get('url'):
video_post_url = post_json_object['object']['url']
else:
video_post_url = post_json_object['object']['id']
video_post_url = remove_html(video_post_url)
if video_post_url in attached_urls:
continue
attached_urls.append(video_post_url)
if not is_muted:
gallery_str += \
' <a href="' + video_url + \
@ -1571,11 +1583,6 @@ def get_post_attachments_as_html(base_dir: str,
gallery_str += ' </video>\n'
gallery_str += ' </figure>\n'
gallery_str += ' </a>\n'
if post_json_object['object'].get('url'):
video_post_url = post_json_object['object']['url']
else:
video_post_url = post_json_object['object']['id']
video_post_url = remove_html(video_post_url)
if image_description and not is_muted:
gallery_str += \
' <a href="' + video_post_url + \