truncate Approved Media Hosts in /formatting

master
Aevann 2023-10-22 23:04:39 +03:00
parent d784bafbce
commit 3ce86d1408
3 changed files with 8 additions and 2 deletions

View File

@ -889,6 +889,12 @@ approved_embed_hosts = [
'i.ytimg.com/vi',
]
approved_embed_hosts_domains = []
for h in approved_embed_hosts:
domain = tldextract.extract(h).registered_domain
if domain not in approved_embed_hosts_domains:
approved_embed_hosts_domains.append(domain)
if SITE_IMAGES not in approved_embed_hosts:
approved_embed_hosts = [SITE_IMAGES] + approved_embed_hosts

View File

@ -376,7 +376,7 @@ def mutes(v):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def formatting(v):
return render_template("formatting.html", v=v, allowed_tags=allowed_tags, allowed_styles=allowed_styles)
return render_template("formatting.html", v=v, allowed_tags=allowed_tags, allowed_styles=allowed_styles, approved_embed_hosts_domains=approved_embed_hosts_domains)
@app.get("/app")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)

View File

@ -456,7 +456,7 @@ And we allow custom HTML in most places:
Image files, video files, and audio files from these sources will get embedded automatically:
<ul class="mt-3">
{% for host in approved_embed_hosts %}
{% for host in approved_embed_hosts_domains %}
<li>{{host}}</li>
{% endfor %}
</ul>