slugify community urls #78

This commit is contained in:
rimu 2024-04-03 20:53:50 +13:00
parent e6431584ab
commit 635449db0f
2 changed files with 3 additions and 0 deletions

View file

@ -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,

View file

@ -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