From 635449db0f8471a5467c3334bf7ccbf79f4e12da Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:53:50 +1300 Subject: [PATCH] slugify community urls #78 --- app/community/routes.py | 2 ++ requirements.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/app/community/routes.py b/app/community/routes.py index 92f534c2..a631051a 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -5,6 +5,7 @@ from random import randint from flask import redirect, url_for, flash, request, make_response, session, Markup, current_app, abort, g, json from flask_login import current_user, login_required from flask_babel import _ +from slugify import slugify from sqlalchemy import or_, desc, text from app import db, constants, cache @@ -47,6 +48,7 @@ def add_local(): # todo: more intense data validation if form.url.data.strip().lower().startswith('/c/'): form.url.data = form.url.data[3:] + form.url.data = slugify(form.url.data) private_key, public_key = RsaKeys.generate_keypair() community = Community(title=form.community_name.data, name=form.url.data, description=form.description.data, rules=form.rules.data, nsfw=form.nsfw.data, private_key=private_key, diff --git a/requirements.txt b/requirements.txt index a1b4ae00..fad9be58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -31,3 +31,4 @@ redis==5.0.1 Werkzeug==2.3.3 pytesseract==0.3.10 sentry-sdk==1.40.6 +python-slugify==8.0.4