From edc511d24af00ff5f175e36a420814fbd707f479 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 14 Nov 2024 19:54:19 +0200 Subject: [PATCH] make repost checking remove the last "/" --- files/routes/posts.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 66307e8d1..a8e494bce 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -439,7 +439,7 @@ def is_repost(v): if not FEATURES['REPOST_DETECTION']: return not_a_repost - url = request.values.get('url') + url = request.values.get('url').rstrip('/') if not url or len(url) < MIN_REPOST_CHECK_URL_LENGTH or not url.startswith('http'): stop(400) @@ -452,7 +452,10 @@ def is_repost(v): url = escape_for_search(url) repost = g.db.query(Post).filter( - Post.url.ilike(url), + or_( + Post.url.ilike(url), + Post.url.ilike(f'{url}/'), + ), Post.deleted_utc == 0, Post.is_banned == False ).first()