forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-08-21 14:30:54 +02:00
parent c6d9f236eb
commit ebb34e29a3
4 changed files with 64 additions and 77 deletions

View File

@ -393,7 +393,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
@property
def is_image(self):
if self.url: return self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('?maxwidth=8888')
if self.url: return self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999')
else: return False
@property

View File

@ -59,8 +59,7 @@ _allowed_styles =[
# filter to make all links show domain on hover
def a_modify(attrs, new=False):
def a_modify(attrs):
raw_url=attrs.get((None, "href"), None)
if raw_url:
@ -85,16 +84,14 @@ def a_modify(attrs, new=False):
return attrs
def sanitize(sanitized):
sanitized = sanitized.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
for i in re.finditer('https://i.imgur.com/(.*?)\.(jpg|png|jpeg|)', sanitized):
sanitized = sanitized.replace(i.group(1), i.group(1) + "_d." + i.group(2))
_clean_wo_links = bleach.Cleaner(tags=_allowed_tags,
attributes=_allowed_attributes,
protocols=_allowed_protocols,
)
_clean_w_links = bleach.Cleaner(tags=_allowed_tags,
sanitized = bleach.Cleaner(tags=_allowed_tags,
attributes=_allowed_attributes,
protocols=_allowed_protocols,
styles=_allowed_styles,
@ -104,15 +101,7 @@ _clean_w_links = bleach.Cleaner(tags=_allowed_tags,
callbacks=[a_modify]
)
]
)
def sanitize(text, linkgen=False):
text = text.replace("\ufeff", "").replace("m.youtube.com", "youtube.com")
if linkgen:
sanitized = _clean_w_links.clean(text)
).clean(sanitized)
#soupify
soup = BeautifulSoup(sanitized, features="html.parser")
@ -170,8 +159,6 @@ def sanitize(text, linkgen=False):
sanitized = str(soup)
else:
sanitized = _clean_wo_links.clean(text)
start = '<s>'
end = '</s>'

View File

@ -4,7 +4,7 @@
{% block content %}
<pre class="d-none d-md-inline-block"></pre>
<h5 style="font-weight:bold;">admins</h5>
<h5 style="font-weight:bold;">Admins</h5>
<pre></pre>
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">

View File

@ -98,7 +98,7 @@
<a class="nav-link{% if request.path.endswith('/leaderboard') %} active{% endif %}" href="/leaderboard"><i class="fas fa-trophy"></i>Leaderboard</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path.endswith('/admins') %} active{% endif %}" href="/admins"><i class="fas fa-crown"></i>admins</a>
<a class="nav-link{% if request.path.endswith('/admins') %} active{% endif %}" href="/admins"><i class="fas fa-crown"></i>Admins</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path.endswith('/log') %} active{% endif %}" href="/log"><i class="fas fa-scroll-old"></i>Moderation Log</a>