From 5b86ee21b0c23749a4648bab370d31779a3fd9e6 Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 26 Jun 2023 18:28:07 +0300 Subject: [PATCH] fix bug that caused urls with quoted spaces to not work https://i.imgur.com/RFyI9jB.png --- files/helpers/sanitize.py | 1 - files/routes/posts.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 0393506f3..edb37bf22 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -660,7 +660,6 @@ def normalize_url(url): url = imgur_regex.sub(r'\1_d.webp?maxwidth=9999&fidelity=grand', url) url = giphy_regex.sub(r'\1.webp', url) - url = unquote(url) return url diff --git a/files/routes/posts.py b/files/routes/posts.py index 158eb9934..9aa7c3cb0 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -5,7 +5,7 @@ from io import BytesIO from os import path from shutil import copyfile from sys import stdout -from urllib.parse import ParseResult, urlparse, urlunparse +from urllib.parse import ParseResult, urlparse, urlunparse, unquote import gevent import requests @@ -407,6 +407,7 @@ def is_repost(v): if not url or len(url) < MIN_REPOST_CHECK_URL_LENGTH: abort(400) url = normalize_url(url) + url = unquote(url) parsed_url = urlparse(url) domain = parsed_url.netloc @@ -496,6 +497,7 @@ def submit_post(v:User, sub=None): if url: url = normalize_url(url) + url = unquote(url) parsed_url = urlparse(url) domain = parsed_url.netloc