From 3f4d671fb70c7ba323604aef23d6b7c8b1b403b2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 15 Sep 2021 14:43:46 +0200 Subject: [PATCH] fd --- files/routes/comments.py | 6 ++++-- files/routes/posts.py | 6 ++++-- files/routes/settings.py | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 95f8e15fc2..3baebbce36 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -161,7 +161,8 @@ def api_comment(v): if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400 - for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): + if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) @@ -604,7 +605,8 @@ def edit_comment(cid, v): if c.is_banned or c.deleted_utc > 0: abort(403) body = request.form.get("body", "")[:10000] - for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): + if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) diff --git a/files/routes/posts.py b/files/routes/posts.py index 9820deb249..0da6a729e5 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -244,7 +244,8 @@ def edit_post(pid, v): p.title_html = filter_title(title) if body != p.body: - for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): + if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) @@ -681,7 +682,8 @@ def submit_post(v): else: return render_template("submit.html", v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.form.get("body", "")), 400 # render text - for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): + if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) diff --git a/files/routes/settings.py b/files/routes/settings.py index 21d53db916..154e65cb80 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -101,7 +101,8 @@ def settings_profile_post(v): if request.values.get("bio"): bio = request.values.get("bio")[:1500] - for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', bio, re.MULTILINE): bio = bio.replace(i.group(1), f'![]({i.group(1)})') + for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', bio, re.MULTILINE): + if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})') bio = bio.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") # check for uploaded image