From 1ad1d61cca0eb9a47c4a7fdd79d0cf6497c80faf Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 00:40:13 +0200 Subject: [PATCH 01/18] fdsdf --- files/routes/posts.py | 4 +--- files/templates/home.html | 4 ---- files/templates/submission.html | 6 +++--- files/templates/submission_listing.html | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 929032741c..3fa301946f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -698,10 +698,8 @@ def submit_post(v): for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: url = url.replace(rd, "https://old.reddit.com/") - - url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery") - url = url.replace("https://mobile.twitter.com", "https://twitter.com").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube") + url = url.replace("old.reddit.com/gallery", "new.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://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") if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/") diff --git a/files/templates/home.html b/files/templates/home.html index 771d5e7357..a12a0bc250 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -3,10 +3,6 @@ {% block desktopBanner %} {% if v %} - {% if v.agendaposter %} - - {% endif %} - {% if not v.fp %} {% endif %} - {% elif "youtu" in p.domain %} + {% elif p.domain in ['youtu.be','youtube.com'] %} {% if 'lite' in p.embed_url %} {{p.embed_url | safe}} {% else %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index c879d27f4b..ef6b82058e 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -491,7 +491,7 @@ - {% elif p.embed_url and "youtu" in p.domain %} + {% elif p.embed_url and p.domain in ['youtu.be','youtube.com'] %}
{% if 'lite' in p.embed_url %} {{p.embed_url | safe}} @@ -499,7 +499,7 @@ {% endif %}
- {% elif p.url and "streamable.com/e/" in p.url %} + {% elif p.url and p.url.startswith('https://streamable.com/e/') %}
From 3faf28605d07e7bb40f3b6deca6c294894deda9a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 00:44:23 +0200 Subject: [PATCH 02/18] fsdfds --- files/helpers/sanitize.py | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 3abf47d7f0..419a818484 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -237,7 +237,7 @@ def sanitize(sanitized, noimages=False): sanitized = sanitized.replace(replacing, htmlsource) for i in re.finditer('

(https:.*?\.mp4)

', sanitized): - sanitized = sanitized.replace(i.group(0), f'

') + sanitized = sanitized.replace(i.group(0), f'

') for i in re.finditer('

diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index ef6b82058e..77cd584298 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -487,7 +487,7 @@ {% if p.url and p.url.lower().endswith('.mp4') %}
-
From b316577d7618611dfe32b383a3f3b901f574ee81 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 01:09:43 +0200 Subject: [PATCH 03/18] sfd --- files/classes/submission.py | 1 + 1 file changed, 1 insertion(+) diff --git a/files/classes/submission.py b/files/classes/submission.py index 8932fa57a1..5d9c62593d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -251,6 +251,7 @@ class Submission(Base): 'distinguish_level': self.distinguish_level, 'voted': self.voted if hasattr(self, 'voted') else 0, 'flags': flags, + 'club': self.club, } if self.ban_reason: From 3634fed841ed4f9eb238fefe51dd9e34a6a86af2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 01:18:06 +0200 Subject: [PATCH 04/18] fsfs --- files/helpers/sanitize.py | 8 +++----- files/routes/awards.py | 6 +++--- files/routes/comments.py | 6 +++--- files/routes/posts.py | 8 ++++---- files/routes/reporting.py | 23 ++++++----------------- files/routes/settings.py | 4 ++-- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 419a818484..4266079e21 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -254,11 +254,9 @@ def sanitize(sanitized, noimages=False): return sanitized -def filter_title(title): - title = title.strip() - title = title.replace("\n", "") - title = title.replace("\r", "") - title = title.replace("\t", "") +def filter_emojis_only(title): + + title = title.replace('<','').replace('>','').replace("\n", "").replace("\r", "").replace("\t", "").strip() title = bleach.clean(title, tags=[]) diff --git a/files/routes/awards.py b/files/routes/awards.py index 716cb4bad2..bc045936bd 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -6,7 +6,7 @@ from files.helpers.const import * from files.classes.award import * from .front import frontlist from flask import g, request -from files.helpers.sanitize import filter_title +from files.helpers.sanitize import filter_emojis_only discounts = { 69: 0.02, @@ -542,7 +542,7 @@ def award_post(pid, v): elif kind == "flairlock": new_name = note[:100].replace("𒐪","") author.customtitleplain = new_name - author.customtitle = filter_title(new_name) + author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = time.time() + 86400 elif kind == "pause": @@ -696,7 +696,7 @@ def award_comment(cid, v): elif kind == "flairlock": new_name = note[:100].replace("𒐪","") author.customtitleplain = new_name - author.customtitle = filter_title(new_name) + author.customtitle = filter_emojis_only(new_name) if len(author.customtitle) > 1000: abort(403) author.flairchanged = time.time() + 86400 elif kind == "pause": diff --git a/files/routes/comments.py b/files/routes/comments.py index f51ec5fc35..fd09998027 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -9,7 +9,7 @@ from files.routes.front import comment_idlist from pusher_push_notifications import PushNotifications from flask import * from files.__main__ import app, limiter -from files.helpers.sanitize import filter_title +from files.helpers.sanitize import filter_emojis_only site = environ.get("DOMAIN").strip() if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" @@ -297,7 +297,7 @@ def api_comment(v): parent_submission=parent_submission, parent_comment_id=c.id, level=level+1, - body_html=filter_title(option), + body_html=filter_emojis_only(option), upvotes=0 ) @@ -657,7 +657,7 @@ def edit_comment(cid, v): parent_submission=c.parent_submission, parent_comment_id=c.id, level=c.level+1, - body_html=filter_title(i.group(1)), + body_html=filter_emojis_only(i.group(1)), upvotes=0 ) g.db.add(c_option) diff --git a/files/routes/posts.py b/files/routes/posts.py index 3fa301946f..f1d431ae2e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -372,7 +372,7 @@ def edit_post(pid, v): title = title.replace('I ', f'@{v.username} ') title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ') - title_html = filter_title(title) + title_html = filter_emojis_only(title) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403 p.title = title p.title_html = title_html @@ -402,7 +402,7 @@ def edit_post(pid, v): c = Comment(author_id=AUTOPOLLER_ID, parent_submission=p.id, level=1, - body_html=filter_title(i.group(1)), + body_html=filter_emojis_only(i.group(1)), upvotes=0 ) g.db.add(c) @@ -681,7 +681,7 @@ def submit_post(v): title = title.replace('I ', f'@{v.username} ') title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ') - title_html = filter_title(title) + title_html = filter_emojis_only(title) body = request.values.get("body", "").strip() if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40 @@ -921,7 +921,7 @@ def submit_post(v): c = Comment(author_id=AUTOPOLLER_ID, parent_submission=new_post.id, level=1, - body_html=filter_title(option), + body_html=filter_emojis_only(option), upvotes=0 ) diff --git a/files/routes/reporting.py b/files/routes/reporting.py index f38a840222..2cc2b3763a 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -3,6 +3,7 @@ from files.helpers.get import * from flask import g from files.__main__ import app, limiter from os import path +from files.helpers.sanitize import filter_emojis_only @app.post("/report/post/") @limiter.limit("1/second") @@ -13,15 +14,12 @@ def api_flag_post(pid, v): if not v.shadowbanned: reason = request.values.get("reason", "").strip()[:100] - if "<" in reason: return {"error": f"Reasons can't contain <"} if not reason.startswith('!'): existing = g.db.query(Flag.id).filter_by(user_id=v.id, post_id=post.id).first() if existing: return "", 409 - for i in re.finditer(':(.{1,30}?):', reason): - if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'): - reason = reason.replace(f':{i.group(1)}:', f':{i.group(1)}:') + reason = filter_emojis_only(reason) if len(reason) > 350: return {"error": f"Too long."} @@ -45,26 +43,17 @@ def api_flag_comment(cid, v): comment = get_comment(cid) if not v.shadowbanned: - existing = g.db.query(CommentFlag.id).filter_by( - user_id=v.id, comment_id=comment.id).first() - + existing = g.db.query(CommentFlag.id).filter_by( user_id=v.id, comment_id=comment.id).first() if existing: return "", 409 - reason = request.values.get("reason", "").strip()[:100] - if "<" in reason: return {"error": f"Reasons can't contain <"} - for i in re.finditer(':(.{1,30}?):', reason): - if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.webp'): - reason = reason.replace(f':{i.group(1)}:', f':{i.group(1)}:') + reason = request.values.get("reason", "").strip()[:100] + reason = filter_emojis_only(reason) if len(reason) > 350: return {"error": f"Too long."} - flag = CommentFlag(comment_id=comment.id, - user_id=v.id, - reason=reason, - ) + flag = CommentFlag(comment_id=comment.id, user_id=v.id, reason=reason) g.db.add(flag) - g.db.commit() return {"message": "Comment reported!"} diff --git a/files/routes/settings.py b/files/routes/settings.py index 5dab1f9d63..06c6a9ae92 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -10,7 +10,7 @@ from files.__main__ import app, cache, limiter import youtube_dl from .front import frontlist import os -from files.helpers.sanitize import filter_title +from files.helpers.sanitize import filter_emojis_only from files.helpers.discord import add_role from shutil import copyfile import requests @@ -1074,7 +1074,7 @@ def settings_title_change(v): v.customtitleplain = new_name - v.customtitle = filter_title(new_name) + v.customtitle = filter_emojis_only(new_name) if len(v.customtitle) < 1000: g.db.add(v) From 49871b4cd896d63353084eedcda7ee92c29ea544 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:08:21 +0200 Subject: [PATCH 05/18] fsdfds --- files/templates/default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/default.html b/files/templates/default.html index 4d9936847b..043e75bd62 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -223,7 +223,7 @@ {% block postNav %} {% endblock %} -
+
From 9a9452734340f2ad4cd0412adae6b51d3501a1e3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:09:49 +0200 Subject: [PATCH 06/18] sdffsd --- files/templates/authforms.html | 8 ++++---- files/templates/default.html | 6 +++--- files/templates/email/default.html | 2 +- files/templates/log.html | 6 +++--- files/templates/login.html | 2 +- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 6 +++--- files/templates/settings2.html | 6 +++--- files/templates/sign_up.html | 4 ++-- files/templates/sign_up_failed_ref.html | 4 ++-- files/templates/submit.html | 8 ++++---- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 558c7092cf..1035862263 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -10,16 +10,16 @@ {% block pagetitle %}{{'SITE_NAME' | app_config}}{% endblock %} - + {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 043e75bd62..f6c163d8c4 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -6,11 +6,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/email/default.html b/files/templates/email/default.html index 7b6b9bfbd6..50146d87f5 100644 --- a/files/templates/email/default.html +++ b/files/templates/email/default.html @@ -8,7 +8,7 @@ - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login.html b/files/templates/login.html index 335b57031a..eb4f3278fa 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -13,7 +13,7 @@ {% block title %} Login - {{'SITE_NAME' | app_config}} {% endblock %} - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index e1376a35a6..6c9d7636ad 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index b6ef4f0894..cf789085f4 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -28,12 +28,12 @@ - + - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index ad5ada3a96..81391bde69 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -33,15 +33,15 @@ {% block pagetitle %}{{'SITE_NAME' | app_config}}{% endblock %} - + {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index a4be0e61de..8e738e57bc 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -27,10 +27,10 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 0fbab61c9e..b995b7b89f 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -28,10 +28,10 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + - + diff --git a/files/templates/submit.html b/files/templates/submit.html index 6dc591e35a..001c0013b4 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -19,18 +19,18 @@ Create a post - {{'SITE_NAME' | app_config}} {% endblock %} - + {% block stylesheets %} {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %} From 3ffae3f46a218e79e3adde97f67f7e55a0fbd402 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:15:43 +0200 Subject: [PATCH 07/18] dfsfd --- files/routes/posts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index f1d431ae2e..a4dafb655e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1096,7 +1096,7 @@ def submit_post(v): if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" body += f'**[{title}]({href})**:\n\n' - if href.startswith('https://old.reddit.com'): + if href.startswith('https://old.reddit.com/'): body += f'* [unddit.com](https://unddit.com/{href.replace("https://old.reddit.com/", "")})\n' body += f'* [archive.org](https://web.archive.org/{href})\n' body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' From 42c889dd09687ff0a9c626c8a601a15d64ac7e5d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:18:56 +0200 Subject: [PATCH 08/18] sfdsdf --- files/templates/votes.html | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/files/templates/votes.html b/files/templates/votes.html index b77f1b62cd..4f5b47bcd3 100644 --- a/files/templates/votes.html +++ b/files/templates/votes.html @@ -6,16 +6,11 @@ {% endblock %} {% block content %} -

Vote Info

- -
- - - -
{% if thing %} - +
+	
+

Info

{{thing.permalink}}

Author: @{{thing.author.username}}

From 89ca7db431b75176ae7d3dc6ea36bb3497e0a346 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:31:19 +0200 Subject: [PATCH 09/18] fdsfsd --- files/helpers/sanitize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 4266079e21..3e8a748717 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -169,7 +169,7 @@ def sanitize(sanitized, noimages=False): old = i.group(0) if 'marseylong1' in old or 'marseylong2' in old or 'marseyllama1' in old or 'marseyllama2' in old: new = old.lower().replace(">", " class='mb-0'>") else: new = old.lower() - for i in re.finditer('(? Date: Wed, 8 Dec 2021 02:49:37 +0200 Subject: [PATCH 10/18] fdsfds --- files/routes/posts.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index a4dafb655e..ac138656f3 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -733,15 +733,14 @@ def submit_post(v): elif "twitter.com" == domain: try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"] except: embed = None - elif "youtu" in domain: - yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) + elif url.startswith('https://youtube.com/watch?v='): + yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0] params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') embed = f'' - elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url: id = url.split("/post/")[1] if "/" in id: id = id.split("/")[0] From 473302e161b9d0be2bca6fc5e3dca9353f2c4e36 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:52:11 +0200 Subject: [PATCH 11/18] sdfsfd --- files/templates/submission.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index 708bb7f676..ddd1e9f95e 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -536,7 +536,7 @@
{% endif %} - {% if p.embed_url and "http" not in p.embed_url %} + {% if p.embed_url and "http" not in p.embed_url and "<" not in p.embed_url %}
From 2fe2b8ac8ea73c98d1721f0bf1d1893721a043a3 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 02:55:02 +0200 Subject: [PATCH 12/18] fdssfd --- files/helpers/sanitize.py | 2 +- files/routes/posts.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 3e8a748717..907f9434bf 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -217,7 +217,7 @@ def sanitize(sanitized, noimages=False): for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))', sanitized): url = i.group(1) - yt_id = i.group(2).split('&')[0] + yt_id = i.group(2).split('&')[0].split('%')[0] replacing = f'{url}' params = parse_qs(urlparse(url).query) diff --git a/files/routes/posts.py b/files/routes/posts.py index ac138656f3..c27e6c90c9 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -734,7 +734,7 @@ def submit_post(v): try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"] except: embed = None elif url.startswith('https://youtube.com/watch?v='): - yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0] + yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0] params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') From 8614b7142f097c3b0105618bd2a702bd877a7635 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 03:03:57 +0200 Subject: [PATCH 13/18] sdffsd --- files/helpers/sanitize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 907f9434bf..10e8592c8b 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -169,7 +169,7 @@ def sanitize(sanitized, noimages=False): old = i.group(0) if 'marseylong1' in old or 'marseylong2' in old or 'marseyllama1' in old or 'marseyllama2' in old: new = old.lower().replace(">", " class='mb-0'>") else: new = old.lower() - for i in re.finditer('(? Date: Wed, 8 Dec 2021 03:54:36 +0200 Subject: [PATCH 14/18] sfdsdf --- files/helpers/sanitize.py | 13 ------------- files/templates/submission.html | 24 +++--------------------- files/templates/submission_listing.html | 12 ++---------- 3 files changed, 5 insertions(+), 44 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 10e8592c8b..0f8c832c41 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -229,22 +229,9 @@ def sanitize(sanitized, noimages=False): htmlsource += '">' sanitized = sanitized.replace(replacing, htmlsource) - - for i in re.finditer('{url}' - htmlsource = f'' - sanitized = sanitized.replace(replacing, htmlsource) - for i in re.finditer('

(https:.*?\.mp4)

', sanitized): sanitized = sanitized.replace(i.group(0), f'

') - for i in re.finditer('{url}' - htmlsource = f'' - sanitized = sanitized.replace(replacing, htmlsource) - for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: sanitized = sanitized.replace(rd, "https://old.reddit.com/") diff --git a/files/templates/submission.html b/files/templates/submission.html index ddd1e9f95e..fba36ea406 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -415,19 +415,7 @@

{% if p.realurl(v) %} - {% if p.url.startswith('https://streamable.com/e/') %} -
-

-							{% elif p.domain == 'open.spotify.com' %}
-								{% if "spotify.com/embed/" in p.realurl(v) %}
-									{% set streamurl=p.realurl(v) %}
-								{% else %}
-									{% set streamurl=p.realurl(v).replace("spotify.com", "spotify.com/embed") %}
-								{% endif %}
-								
-								

-
-							{% elif not p.embed_url and not p.is_image and not (p.url and p.url.lower().endswith('.mp4')) %}
+							{% if not p.embed_url and not p.is_image and not (p.url and p.url.lower().endswith('.mp4')) %}
 								
 									
{{p.domain|truncate(30, True)}} @@ -483,14 +471,8 @@ {% endif %} - {% elif p.domain in ['youtu.be','youtube.com'] %} - {% if 'lite' in p.embed_url %} - {{p.embed_url | safe}} - {% else %} -
- -
- {% endif %} + {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith('
- {% elif p.embed_url and p.domain in ['youtu.be','youtube.com'] %} + {% elif p.embed_url and p.domain in ['youtu.be','youtube.com'] and p.embed_url.startswith(' - {% if 'lite' in p.embed_url %} - {{p.embed_url | safe}} - {% else %} - - {% endif %} -
- {% elif p.url and p.url.startswith('https://streamable.com/e/') %} -
- + {{p.embed_url | safe}}
{% endif %} {% endif %} From 44e90d9b7bc1abaede56a7562feea06a476d7309 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 04:03:12 +0200 Subject: [PATCH 15/18] sfdsfd --- files/helpers/sanitize.py | 2 +- files/routes/posts.py | 2 +- files/templates/submission.html | 31 +++++++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 0f8c832c41..fe743774b6 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -212,7 +212,6 @@ def sanitize(sanitized, noimages=False): 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") - if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=") for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))
', sanitized): @@ -220,6 +219,7 @@ def sanitize(sanitized, noimages=False): yt_id = i.group(2).split('&')[0].split('%')[0] replacing = f'{url}' + print(url) params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') diff --git a/files/routes/posts.py b/files/routes/posts.py index c27e6c90c9..99ebea6933 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -699,7 +699,7 @@ def submit_post(v): for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: url = url.replace(rd, "https://old.reddit.com/") - url = url.replace("old.reddit.com/gallery", "new.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://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") + url = url.replace("old.reddit.com/gallery", "new.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://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").replace("https://www.youtube", "https://youtube") if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/") diff --git a/files/templates/submission.html b/files/templates/submission.html index fba36ea406..cd9ad5c7e9 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -424,6 +424,23 @@ {% endif %} {% endif %} + + + {% if p.embed_url %} + {% if p.domain == "twitter.com" %} + {{p.embed_url | safe}} + {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %} + + {% else %} + + {% endif %} + + {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith(' {% if p.is_image %}
@@ -462,20 +479,6 @@
- {% if p.embed_url %} - {% if p.domain == "twitter.com" %} - {{p.embed_url | safe}} - {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %} - - {% else %} - - {% endif %} - - {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith(' From 969013a501177629a305b55f7eff6f8c010ff9be Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 04:05:29 +0200 Subject: [PATCH 16/18] sfdfsd --- files/helpers/sanitize.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index fe743774b6..ead7cf741c 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -219,8 +219,7 @@ def sanitize(sanitized, noimages=False): yt_id = i.group(2).split('&')[0].split('%')[0] replacing = f'{url}' - print(url) - params = parse_qs(urlparse(url).query) + params = parse_qs(urlparse(url.replace('&','&')).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') From b3df99cdb41e39669329b7ac44f75762ffbde092 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 04:19:46 +0200 Subject: [PATCH 17/18] fdsfds --- files/templates/default.html | 2 +- files/templates/login.html | 2 +- files/templates/settings.html | 2 +- files/templates/settings2.html | 2 +- files/templates/submit.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/templates/default.html b/files/templates/default.html index f6c163d8c4..26807952ac 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -13,7 +13,7 @@ {% endif %} - + diff --git a/files/templates/login.html b/files/templates/login.html index eb4f3278fa..3ce8c04cf9 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -17,7 +17,7 @@ - + diff --git a/files/templates/settings.html b/files/templates/settings.html index cf789085f4..9fb880307e 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -35,7 +35,7 @@ {% if v.agendaposter %}{% elif v.css %}{% endif %} - + diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 81391bde69..5271119bf6 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -44,7 +44,7 @@ {% endif %} - + diff --git a/files/templates/submit.html b/files/templates/submit.html index 001c0013b4..01a198f132 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -34,7 +34,7 @@ {% endif %} {% endblock %} - + From f51ce88c0c30921310e2da59d11bceddc177b633 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 04:38:58 +0200 Subject: [PATCH 18/18] sdffsd --- files/templates/authforms.html | 6 ++---- files/templates/default.html | 4 ++-- files/templates/email/default.html | 6 ++---- files/templates/log.html | 4 ++-- files/templates/login.html | 9 ++++----- files/templates/login_2fa.html | 2 +- files/templates/settings.html | 3 +-- files/templates/settings2.html | 6 ++---- files/templates/sign_up.html | 4 +--- files/templates/sign_up_failed_ref.html | 4 +--- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 6 +++++- files/templates/submit.html | 6 ++---- 13 files changed, 26 insertions(+), 36 deletions(-) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 1035862263..d46907db0b 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -10,16 +10,14 @@ {% block pagetitle %}{{'SITE_NAME' | app_config}}{% endblock %} - - {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 26807952ac..89007c301e 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -5,12 +5,12 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/email/default.html b/files/templates/email/default.html index 50146d87f5..b81768cd03 100644 --- a/files/templates/email/default.html +++ b/files/templates/email/default.html @@ -7,9 +7,7 @@ - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %}
diff --git a/files/templates/login.html b/files/templates/login.html index 3ce8c04cf9..e8ee91ee9b 100644 --- a/files/templates/login.html +++ b/files/templates/login.html @@ -13,11 +13,10 @@ {% block title %} Login - {{'SITE_NAME' | app_config}} {% endblock %} - - - - - + + + + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index 6c9d7636ad..99059ed080 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -12,7 +12,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + diff --git a/files/templates/settings.html b/files/templates/settings.html index 9fb880307e..04c0566f41 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -28,11 +28,10 @@ - - + {% if v.agendaposter %}{% elif v.css %}{% endif %} diff --git a/files/templates/settings2.html b/files/templates/settings2.html index 5271119bf6..360570ef96 100644 --- a/files/templates/settings2.html +++ b/files/templates/settings2.html @@ -33,15 +33,13 @@ {% block pagetitle %}{{'SITE_NAME' | app_config}}{% endblock %} - - {% if v %} - + {% else %} - + {% endif %} diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 8e738e57bc..b6d249593e 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -27,10 +27,8 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - - - + diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index b995b7b89f..62b0973f60 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -28,10 +28,8 @@ {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - - - + diff --git a/files/templates/submission.html b/files/templates/submission.html index cd9ad5c7e9..da99c2b4c3 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -446,7 +446,7 @@ diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 786d6781cb..d679f2588c 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -492,7 +492,7 @@
{% elif p.embed_url and p.domain in ['youtu.be','youtube.com'] and p.embed_url.startswith(' +
{{p.embed_url | safe}}
{% endif %} @@ -647,6 +647,10 @@ background: -webkit-linear-gradient(left, red, orange, yellow, green, blue, indigo, violet ); text-shadow:-1px -1px 0 black,1px -1px 0 black,-1px 1px 0 black,1px 1px 0 black; } + + lite-youtube { + margin: auto + } diff --git a/files/templates/submit.html b/files/templates/submit.html index 01a198f132..416b7e0101 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -19,17 +19,15 @@ Create a post - {{'SITE_NAME' | app_config}} {% endblock %} - - {% block stylesheets %} {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} {% endblock %}