forked from MarseyWorld/MarseyWorld
fdsfds
parent
96362089da
commit
f27a42bdcf
|
@ -183,7 +183,7 @@ def sanitize(sanitized, noimages=False):
|
||||||
remoji = emoji
|
remoji = emoji
|
||||||
|
|
||||||
if path.isfile(f'./files/assets/images/emojis/{remoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{remoji}.webp'):
|
||||||
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" {classes}src="https://{site}/assets/images/emojis/{remoji}.webp" >', new)
|
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" {classes}src="https://{site}/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace(old, new)
|
sanitized = sanitized.replace(old, new)
|
||||||
|
|
||||||
|
@ -193,10 +193,10 @@ def sanitize(sanitized, noimages=False):
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 class="emj mirrored" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
|
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 class="emj mirrored" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emj" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized)
|
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emj" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").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("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").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("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
||||||
|
|
||||||
|
@ -235,15 +235,15 @@ def filter_emojis_only(title):
|
||||||
title = bleach.clean(title, tags=[])
|
title = bleach.clean(title, tags=[])
|
||||||
|
|
||||||
for i in re.finditer('(?<!"):([!A-Za-z0-9]{1,30}?):', title):
|
for i in re.finditer('(?<!"):([!A-Za-z0-9]{1,30}?):', title):
|
||||||
emoji = i.group(1)
|
emoji = i.group(1).lower()
|
||||||
|
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp" class="emj mirrored">', title)
|
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}:" title=":!{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp" class="emj mirrored">', title, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emj" src="https://{site}/assets/images/emojis/{emoji}.webp">', title)
|
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emj" src="https://{site}/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
||||||
|
|
||||||
if len(title) > 1500: abort(400)
|
if len(title) > 1500: abort(400)
|
||||||
else: return title
|
else: return title
|
|
@ -157,7 +157,7 @@ def api_comment(v):
|
||||||
else: top_comment_id = parent.top_comment_id
|
else: top_comment_id = parent.top_comment_id
|
||||||
else: abort(400)
|
else: abort(400)
|
||||||
|
|
||||||
body = request.values.get("body", "").strip()[:10000]
|
body = request.values.get("body", "").strip()[:10000].upper()
|
||||||
|
|
||||||
if v.marseyawarded:
|
if v.marseyawarded:
|
||||||
if time.time() > v.marseyawarded:
|
if time.time() > v.marseyawarded:
|
||||||
|
@ -615,7 +615,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
if c.is_banned or c.deleted_utc > 0: abort(403)
|
if c.is_banned or c.deleted_utc > 0: abort(403)
|
||||||
|
|
||||||
body = request.values.get("body", "").strip()[:10000]
|
body = request.values.get("body", "").strip()[:10000].upper()
|
||||||
if len(body) < 1: return {"error":"You have to actually type something!"}, 400
|
if len(body) < 1: return {"error":"You have to actually type something!"}, 400
|
||||||
|
|
||||||
if body != c.body and body != "":
|
if body != c.body and body != "":
|
||||||
|
|
|
@ -335,8 +335,8 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403)
|
if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403)
|
||||||
|
|
||||||
title = request.values.get("title", "").strip()
|
title = request.values.get("title", "").strip().upper()
|
||||||
body = request.values.get("body", "").strip()
|
body = request.values.get("body", "").strip().upper()
|
||||||
|
|
||||||
if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403
|
if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ def submit_post(v):
|
||||||
if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413
|
if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413
|
||||||
elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413
|
elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413
|
||||||
|
|
||||||
title = request.values.get("title", "").strip()[:500]
|
title = request.values.get("title", "").strip()[:500].upper()
|
||||||
url = request.values.get("url", "").strip()
|
url = request.values.get("url", "").strip()
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded:
|
||||||
|
@ -678,7 +678,7 @@ def submit_post(v):
|
||||||
title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ')
|
title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ')
|
||||||
|
|
||||||
title_html = filter_emojis_only(title)
|
title_html = filter_emojis_only(title)
|
||||||
body = request.values.get("body", "").strip()
|
body = request.values.get("body", "").strip().upper()
|
||||||
|
|
||||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40
|
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue