forked from rDrama/rDrama
tmufdsMerge branch 'frost' of https://github.com/Aevann1/Drama into frost
commit
9798a70fb9
|
@ -10,6 +10,8 @@ from json import loads, dump
|
||||||
from random import random, choice
|
from random import random, choice
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import ParseResult, urlunparse, urlparse
|
||||||
|
|
||||||
|
|
||||||
allowed_tags = tags = ['b',
|
allowed_tags = tags = ['b',
|
||||||
'blockquote',
|
'blockquote',
|
||||||
|
@ -115,7 +117,13 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
|
|
||||||
sanitized = strikethrough_regex.sub(r'<del>\1</del>', sanitized)
|
sanitized = strikethrough_regex.sub(r'<del>\1</del>', sanitized)
|
||||||
|
|
||||||
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace("script>","").replace('','')
|
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace("script>","").replace('','').replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube").replace("old.reddit.com/gallery", "reddit.com/gallery")
|
||||||
|
|
||||||
|
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||||
|
|
||||||
|
for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
|
||||||
|
sanitized = sanitized.replace(rd, "://old.reddit.com")
|
||||||
|
|
||||||
|
|
||||||
if alert:
|
if alert:
|
||||||
captured = []
|
captured = []
|
||||||
|
@ -195,6 +203,32 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
except: tag.string = ""
|
except: tag.string = ""
|
||||||
|
|
||||||
|
|
||||||
|
parsed_url = urlparse(tag.get("href"))
|
||||||
|
|
||||||
|
domain = parsed_url.netloc
|
||||||
|
if domain == 'old.reddit.com':
|
||||||
|
new_url = ParseResult(scheme="https",
|
||||||
|
netloc=parsed_url.netloc,
|
||||||
|
path=parsed_url.path,
|
||||||
|
params=parsed_url.params,
|
||||||
|
query=None,
|
||||||
|
fragment=parsed_url.fragment)
|
||||||
|
else:
|
||||||
|
qd = parse_qs(parsed_url.query)
|
||||||
|
filtered = {k: val for k, val in qd.items() if not k.startswith('utm_') and not k.startswith('ref_')}
|
||||||
|
|
||||||
|
new_url = ParseResult(scheme="https",
|
||||||
|
netloc=parsed_url.netloc,
|
||||||
|
path=parsed_url.path,
|
||||||
|
params=parsed_url.params,
|
||||||
|
query=urlencode(filtered, doseq=True),
|
||||||
|
fragment=parsed_url.fragment)
|
||||||
|
|
||||||
|
|
||||||
|
new_url = urlunparse(new_url)
|
||||||
|
if tag.string == tag["href"]: tag.string = new_url
|
||||||
|
tag["href"] = new_url
|
||||||
|
|
||||||
|
|
||||||
sanitized = str(soup)
|
sanitized = str(soup)
|
||||||
|
|
||||||
|
@ -276,10 +310,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
sanitized = re.sub(f'(?<!"):{i.group(1).lower()}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" class="{classes}" src="/e/{emoji}.webp">', sanitized, flags=re.I|re.A)
|
sanitized = re.sub(f'(?<!"):{i.group(1).lower()}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" class="{classes}" src="/e/{emoji}.webp">', sanitized, flags=re.I|re.A)
|
||||||
if comment: marseys_used.add(emoji)
|
if comment: marseys_used.add(emoji)
|
||||||
|
|
||||||
sanitized = sanitized.replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
|
|
||||||
|
|
||||||
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
|
||||||
|
|
||||||
captured = []
|
captured = []
|
||||||
for i in youtube_regex.finditer(sanitized):
|
for i in youtube_regex.finditer(sanitized):
|
||||||
if i.group(0) in captured: continue
|
if i.group(0) in captured: continue
|
||||||
|
@ -299,11 +329,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
||||||
|
|
||||||
sanitized = sanitized.replace(replacing, htmlsource)
|
sanitized = sanitized.replace(replacing, htmlsource)
|
||||||
|
|
||||||
for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
|
|
||||||
sanitized = sanitized.replace(rd, "://old.reddit.com")
|
|
||||||
|
|
||||||
sanitized = sanitized.replace("old.reddit.com/gallery", "reddit.com/gallery")
|
|
||||||
|
|
||||||
|
|
||||||
sanitized = unlinked_regex.sub(r'\1<a href="\2" rel="nofollow noopener noreferrer" target="_blank">\2</a>', sanitized)
|
sanitized = unlinked_regex.sub(r'\1<a href="\2" rel="nofollow noopener noreferrer" target="_blank">\2</a>', sanitized)
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,6 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
|
||||||
|
|
||||||
month = datetime.now().strftime('%B')
|
month = datetime.now().strftime('%B')
|
||||||
|
|
||||||
@app.get('/admin/default')
|
|
||||||
@admin_level_required(3)
|
|
||||||
def default(v):
|
|
||||||
for u in g.db.query(User).filter(User.profileurl == None).all():
|
|
||||||
u.profileurl = '/e/' + random.choice(marseys_const) + '.webp'
|
|
||||||
g.db.add(u)
|
|
||||||
print(u.username, flush=True)
|
|
||||||
g.db.commit()
|
|
||||||
return 'done'
|
|
||||||
|
|
||||||
@app.get('/admin/merge/<id1>/<id2>')
|
@app.get('/admin/merge/<id1>/<id2>')
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def merge(v, id1, id2):
|
def merge(v, id1, id2):
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<script src="/static/assets/js/bootstrap.js?v=245"></script>
|
<script src="/static/assets/js/bootstrap.js?v=245"></script>
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="modal fade" id="gifModal" tabindex="-1" role="dialog" aria-labelledby="gifModalTitle" aria-hidden="true">
|
<div class="modal fade" id="gifModal" tabindex="-1" role="dialog" aria-labelledby="gifModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-5" style="max-width:100% !important" role="document">
|
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-4" style="max-width:100% !important" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header border-bottom-0 shadow-md p-3">
|
<div class="modal-header border-bottom-0 shadow-md p-3">
|
||||||
<div class="form-group d-flex align-items-center w-100 mb-0">
|
<div class="form-group d-flex align-items-center w-100 mb-0">
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row justify-content-around">
|
<div class="row justify-content-around">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<title>2-Step Login - {{SITE_NAME}}</title>
|
<title>2-Step Login - {{SITE_NAME}}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
|
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
|
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
|
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue