forked from MarseyWorld/MarseyWorld
master
parent
4f283e0764
commit
7015e93a07
|
@ -276,7 +276,12 @@ 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("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").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("https://www.twitter", "https://twitter")
|
|
||||||
|
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("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").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("https://www.twitter", "https://twitter").replace("https://www.instagram", "https://instagram").replace("https://www.tiktok", "https://tiktok")
|
||||||
|
|
||||||
|
|
||||||
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||||
|
|
||||||
|
@ -299,9 +304,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 = 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)
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,8 @@ def front_all(v, sub=None, subdomain=None):
|
||||||
if not v and request.path == "/" and not request.headers.get("Authorization"):
|
if not v and request.path == "/" and not request.headers.get("Authorization"):
|
||||||
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||||
|
|
||||||
|
if v and request.path.startswith('/logged_out'): v = None
|
||||||
|
|
||||||
try: page = max(int(request.values.get("page", 1)), 1)
|
try: page = max(int(request.values.get("page", 1)), 1)
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
|
||||||
|
|
|
@ -794,7 +794,7 @@ def submit_post(v, sub=None):
|
||||||
title = request.values.get("title", "").strip()[:500].replace('','')
|
title = request.values.get("title", "").strip()[:500].replace('','')
|
||||||
|
|
||||||
url = request.values.get("url", "").strip()
|
url = request.values.get("url", "").strip()
|
||||||
|
|
||||||
body = request.values.get("body", "").strip().replace('','')
|
body = request.values.get("body", "").strip().replace('','')
|
||||||
|
|
||||||
def error(error):
|
def error(error):
|
||||||
|
@ -840,21 +840,21 @@ def submit_post(v, sub=None):
|
||||||
embed = None
|
embed = None
|
||||||
|
|
||||||
if url:
|
if url:
|
||||||
url = url.replace("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").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("https://www.twitter", "https://twitter")
|
for rd in ("://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it", "://teddit.net"):
|
||||||
|
url = url.replace(rd, "://old.reddit.com")
|
||||||
|
|
||||||
|
url = url.replace("nitter.net", "twitter.com").replace("old.reddit.com/gallery", "reddit.com/gallery").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("https://www.twitter", "https://twitter").replace("https://www.instagram", "https://instagram").replace("https://www.tiktok", "https://tiktok")
|
||||||
|
|
||||||
if "/i.imgur.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp")
|
if "/i.imgur.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp")
|
||||||
elif "/media.giphy.com/" in url or "/c.tenor.com/" in url: url = url.replace(".gif", ".webp")
|
elif "/media.giphy.com/" in url or "/c.tenor.com/" in url: url = url.replace(".gif", ".webp")
|
||||||
elif "/i.ibb.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp").replace(".gif", ".webp")
|
elif "/i.ibb.com/" in url: url = url.replace(".png", ".webp").replace(".jpg", ".webp").replace(".jpeg", ".webp").replace(".gif", ".webp")
|
||||||
|
|
||||||
for rd in ("://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it", "://teddit.net"):
|
|
||||||
url = url.replace(rd, "://old.reddit.com")
|
|
||||||
|
|
||||||
if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/")
|
if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/")
|
||||||
|
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
|
||||||
domain = parsed_url.netloc
|
domain = parsed_url.netloc
|
||||||
if domain == 'old.reddit.com':
|
if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com'):
|
||||||
new_url = ParseResult(scheme="https",
|
new_url = ParseResult(scheme="https",
|
||||||
netloc=parsed_url.netloc,
|
netloc=parsed_url.netloc,
|
||||||
path=parsed_url.path,
|
path=parsed_url.path,
|
||||||
|
|
Loading…
Reference in New Issue